Sull Posted February 20, 2008 Share Posted February 20, 2008 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 youSull Link to comment Share on other sites More sharing options...
Yzöwl Posted February 20, 2008 Share Posted February 20, 2008 A quick reminder to anyone replying...Make sure that D: is not an optical or removable drive. Link to comment Share on other sites More sharing options...
cyberpyr8 Posted February 20, 2008 Share Posted February 20, 2008 You can script it through a batch file. It would be something like:if exist d:\ goto scriptgoto end:scriptregedit /S filename.reg:endexitIs that what you are looking for? Link to comment Share on other sites More sharing options...
Sull Posted February 21, 2008 Author Share Posted February 21, 2008 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 Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 21, 2008 Share Posted February 21, 2008 Here is a VBS script that checks1:\ It a hard drive2:\ Checks For D Drive3:\ Checks To Make Sure The Reg File ExistsYou 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 Link to comment Share on other sites More sharing options...
Sull Posted February 21, 2008 Author Share Posted February 21, 2008 Thank you, would the location below be ok ? Dim Act :Set Act = CreateObject("Wscript.Shell")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Drv, RegReg = "%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 NextNow can I just run this script from my cleanup.cmd ? Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 22, 2008 Share Posted February 22, 2008 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, RegReg = 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 NextNow can I just run this script from my cleanup.cmd ?Yes you can Link to comment Share on other sites More sharing options...
Sull Posted February 22, 2008 Author Share Posted February 22, 2008 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 helpSull Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 22, 2008 Share Posted February 22, 2008 This The Hey, Scripting Guy! Archive is a very good place to learn about VBS Scripts. Link to comment Share on other sites More sharing options...
MHz Posted February 23, 2008 Share Posted February 23, 2008 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). Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 23, 2008 Share Posted February 23, 2008 Thanks for the nice wordsI forgot to even mention the Jscript56.chm as a source. You can also update the script engine to 5.7Results for - Windows Script 5.7 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now