Jump to content

Recommended Posts

Posted

I would like to change My Documents to D:\ but only if D:\ exists, I don't know what command would do this. I found this in another thread which changes My Documents to D:\

;Change location of my documents
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
"Personal" ="D:\\"

I would like for it to look if D:\ exists and if it does then apply the reg entry..

Thank you

Sull


Posted

You can script it through a batch file. It would be something like:

if exist d:\ goto script

goto end

:script

regedit /S filename.reg

:end

exit

Is that what you are looking for?

Posted

Yes that is what I am looking for, now will that work or does it need to be more advanced than that ?

also as Yzöwl said make sure D:\ is not CD/DVD or removable

Posted

Here is a VBS script that checks

1:\ It a hard drive

2:\ Checks For D Drive

3:\ Checks To Make Sure The Reg File Exists

You will have to supply the path to the reg file

Save As CheckDrv.vbs

 Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Drv, Reg
Reg = "Your\Path\To\Reg.reg"
For Each Drv In Fso.Drives
If Drv.DriveType = 2 Then '-> Make Sure It A Hard Drive
If InStr(Drv.DriveLetter,"D") Then '-> Checks The Drive Letter
If Fso.FileExists(Reg) Then '-> Make Sure The Reg File Exists
Act.Run("regedit /S " & Reg),0,True
End If
End If
End If
Next

Posted

Thank you, would the location below be ok ?

 Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Drv, Reg
Reg = "%SYSTEMDRIVE%\Install\DS.reg"
For Each Drv In Fso.Drives
If Drv.DriveType = 2 Then '-> Make Sure It A Hard Drive
If InStr(Drv.DriveLetter,"D") Then '-> Checks The Drive Letter
If Fso.FileExists(Reg) Then '-> Make Sure The Reg File Exists
Act.Run("regedit /S " & Reg),0,True
End If
End If
End If
Next

Now can I just run this script from my cleanup.cmd ?

Posted

Thank you, would the location below be ok ?

No Change It To This

 Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Drv, Reg
Reg = Act.ExpandEnvironmentStrings("%SYSTEMDRIVE%\Install\DS.reg")
For Each Drv In Fso.Drives
If Drv.DriveType = 2 Then '-> Make Sure It A Hard Drive
If InStr(Drv.DriveLetter,"D") Then '-> Checks The Drive Letter
If Fso.FileExists(Reg) Then '-> Make Sure The Reg File Exists
Act.Run("regedit /S " & Reg),0,True
End If
End If
End If
Next

Now can I just run this script from my cleanup.cmd ?

Yes you can

Posted

gunsmokingman,

Thanks I will test it out soon. I would like to learn how to write these vbs scripts, do you know of any good sites or guides ?

Appreciate the help

Sull

Posted

gunsmokingman is the VBS scripting guy around these parts (except for the other scripting guy in the link given, :)), but if your into VBS then the script56.chm is quite valuable also (at least for me).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...