jhn_bengtsson Posted October 12, 2006 Share Posted October 12, 2006 Hi!I have created following:Dim RegSet Reg = CreateObject("wscript.shell")Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUNONCE\" & "NAME", "PATH" & "\" & "NAME" & ".vbs"With that .vbs file I want to run a .bat on a cdrom at startup in windows, is that possible? The problem is that I can not be sure that the CDrom drives "path" is the same all the time so I need a loop untill the script finds the right path, please help me!! And if its possible to do that, how can the script understand that the cd drive is mounted at the startup, if the cdrom drive is not "mounted" then the script wont run. I know I can use Wscipt.sleep but will that work?I have tried Set objShell = CreateObject("WScript.Shell")Set objFSO = CreateObject("Scripting.FileSystemObject")If objFSO.DriveExists("D:\") ThenobjShell.Run("D:\Name.bat")ElseIf objFSO.DriveExists("E:\") ThenobjShell.Run("E:\Name.bat")'and so on and so onEnd IfBut it wont go, please help me Link to comment Share on other sites More sharing options...
jondercik Posted October 12, 2006 Share Posted October 12, 2006 why not after the drive check, also check to make sure the file exists there as well? Link to comment Share on other sites More sharing options...
jhn_bengtsson Posted October 12, 2006 Author Share Posted October 12, 2006 How can I get runonce to see if "drive check" loading is complete?And the file exists, its on my cd I dont know if thats the problem, I think its my script to call the cd.. Link to comment Share on other sites More sharing options...
gunsmokingman Posted October 12, 2006 Share Posted October 12, 2006 Try this VBS scriptSave as RunFrom_CDDVD.vbsDim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Dim Act : Set Act = CreateObject("Wscript.Shell")Dim Drv, StrD Set Drv = Fso.Drives For Each StrD In Drv If StrD.DriveType = 4 Then If StrD.IsReady = True Then '/-> PLACE THE FILE NAME THAT YOU WANT TO CHECK FOR HERE If Fso.FileExists(StrD & "\SETUP.EXE") Then WScript.Echo "Confirm " & StrD & "\SETUP.EXE"'/-> RUNS THE FILE FROM THE CD OR DVD DRIVE UNCOMMENT TO MAKE ACTIVE ' Act.Run("%Comspec% /C " & StrD & "\Name.bat"), 1, True End If End If End If Next Link to comment Share on other sites More sharing options...
jhn_bengtsson Posted October 19, 2006 Author Share Posted October 19, 2006 Hi..I manage to complete the script and this is it.This installation is either to a laptop or a desktop thats why i use temp1.txt or temp2.txt to locate witch installation that needs to be installed..All scripts exists on a CD at the begining, and the user only needs to puch one buttom And the first script is for desktop users.. bind with a buttom on the cd_startmenuSet objFSO = CreateObject("Scripting.FileSystemObject")Set objShell = WScript.CreateObject("WScript.Shell")Set Reg = CreateObject("wscript.shell")Dim objFSODim objShellDim RegIf objFSO.FolderExists("C:\Program Files\F-Secure")Then Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUNONCE\" & "cd", "C:\" & "runcd" & ".vbs" objShell.Run("uninstall.exe /S") objFSO.CreateTextFile("C:\Temp1.txt") Set objFileCopy = objFSO.GetFile("runcd.vbs") objFileCopy.Copy ("C:\runcd.vbs")Else objShell.Run("ILAUNCHR.EXE jar\install_desktop.jar /U /C")End IfThis is the script that the erlier script puts out to C:\.. Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Dim Act : Set Act = WScript.CreateObject("Wscript.Shell")Dim Drv, StrD, DriveSet Drv = Fso.Drives For Each StrD In Drv If StrD.DriveType = 4 Then If StrD.IsReady = True Then If Fso.FileExists(StrD & "\runcd.vbs") Then Set Drive = StrD If Fso.FileExists("C:\Temp1.txt") Then Act.Run(StrD & "\ILAUNCHR.EXE " & StrD & "\jar\install_desktop.jar /C /U") Fso.DeleteFile("C:\Temp1.txt") End If If Fso.FileExists("C:\Temp2.txt") Then Act.run(StrD & "\ILAUNCHR.EXE´" & StrD & "\jar\install_laptop.jar /C /U") Fso.DeleteFile("C:\Temp2.txt") End If End If End If End If NextSet Drv = Fso.Drives For Each StrD In Drv If StrD.DriveType = 4 Then If StrD.IsReady = True Then Set Drive = StrD Act.Run(StrD & "\cleanup.vbs") End If End If NextAnd this script is the cleanup.vbs Dim FsoSet Fso = CreateObject("Scripting.FileSystemObject")Do Until i = IsReadyi = ("C:\runcd.vbs")LoopFso.DeleteFile("C:\runcd.vbs"), TrueWell thats it folks.. thx for the help gunsmokingman B)And yes im not the perfect man on this job but i did it, and there is some lines that i dont need at all.. but i will keep it there Its working and Im happy B) 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