Login | |
|
 |
RE: changing drive with cmd - 8/19/2005 4:33:46 AM
|
|
 |
|
| |
Country73
Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
I'm not sure I'm following you on this.. You have a VBScript that creates a registry key so that on reboot it kicks off another VBScript that resides on your CD-Rom drive? If you're wanting a script to launch a script off of your CD, then you should be able to use this: strDrive = "CDRom drive letter" Set oShell = CreateObject("Wscript.Shell") oShell.Run strDrive & "\myScript.vbs",0,True
|
|
| |
|
|
|
 |
RE: changing drive with cmd - 8/19/2005 5:01:01 AM
|
|
 |
|
| |
mbouchard
Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
Quick question, what are you using to get the letter of the CD? Also, just to add to what Country73 said, Most times when you use WMI/vbscript to return a drive letter you will only get something like this: X: there is no \ at the end, so you will need to add it. ex. On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive") For Each objItem in colItems msg = msg & "before: " & objItem.Drive & vbcr & "After: " & objItem.Drive & "\" & vbcr Next msgbox msg
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
 |
RE: changing drive with cmd - 8/19/2005 6:04:46 AM
|
|
 |
|
| |
Country73
Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
What's the exact entry you have in your registry? I messed around with mine a little bit and was able to get my script to run from floppy and CD. When you are retrieving the information for your CD drive, what script is doing that? Does that reside in your Temp directory? My registry entry: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce Name: myScript Type: REG_SZ Data: D:\myEcho.vbs D:\ = my CD Drive This script just launches a msgbox "Hello!"
|
|
| |
|
|
|
 |
RE: changing drive with cmd - 8/22/2005 1:03:46 AM
|
|
 |
|
| |
Country73
Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
Sorry I didn't get a chance to reply back this weekend; flag football for the little ones is just starting up! OK, I just tested this again and this should work out for you. '----------First Script (creates the registry key used for after reboot)--------- 'Run_Once_Reg.vbs '------------------------ Set oFS = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") SLOCAL = oFS.GetAbsolutePathName(".") WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\Test", SLOCAL & "\myEcho.vbs", "REG_SZ" '----------Second Script (Just a msgbox to show the registry key took)------------ 'myEcho.vbs '-------------- wscript.echo "Hello!" Let us know if that works out for you or not.
|
|
| |
|
|
|
 |
RE: changing drive with cmd - 8/22/2005 2:53:25 AM
|
|
 |
|
| |
Country73
Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
Try rulling the CD-Rom out of it. If you create a basic script at "C:\Temp\myscript.vbs" and then create the registry key to point to it, does the script run that way? It may take a little longer for the script to start when running from CD. I ran it on my machine and it only took a few seconds, but as soon as I logged in I could hear the CD Drive start up.
|
|
| |
|
|
|
 |
RE: changing drive with cmd - 8/22/2005 3:38:23 AM
|
|
 |
|
| |
Country73
Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
Yeah, I was just curious. It seems to be running from my machine with no problem, so I don't know what the issue might be...
|
|
| |
|
|
|
 |
RE: changing drive with cmd - 8/22/2005 4:15:51 AM
|
|
 |
|
| |
Country73
Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
I don't know what all you have going on with that machine, so I'm just trying to put the peices together in my head. You create a new account, reboot machine, auto logon with new account, script never runs. Are there any other applications launching at login? When the machine is logged into with the new account, does it have access to the CD Drive? Can you manually go in and launch the script while that account is logged into the machine?
|
|
| |
|
|
|
 |
RE: changing drive with cmd - 8/22/2005 5:26:20 AM
|
|
 |
|
| |
Country73
Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
I really don't think the registry key is the problem, but the script won't launch (from that account) unless you manually launch it from the CD and your regular account will launch the script from the registry key... Be sure this script is ran from your CD since one variable is created by where the first script is ran from. Probably a million different ways to write this, but here's one way. Change / modify what's in RED for your purpose. Set oFS = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") SLOCAL = oFS.GetAbsolutePathName(".") '===================== 'Grabs the full path to current script '===================== SSTART = "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\" '==================== 'Location to create startup script '==================== '========================================= 'Create the startup script '========================================= Set myFile = oFS.OpenTextFile(SSTART & "kickOff.vbs",8,True) myFile.WriteLine "Set oFS = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & ")" myFile.WriteLine "Set WshShell = Wscript.CreateObject(" & chr(34) & "WScript.Shell" & chr(34) & ")" myFile.WriteLine "WshShell.Run chr(34) & " & chr(34) & SLOCAL & "\myEcho.vbs" & chr(34) & " & chr(34)" myFile.WriteLine "myFile = oFS.GetAbsolutePathName(" & chr(34) & "." & chr(34) & ")" myFile.WriteLine "oFS.DeleteFile myFile & " & chr(34) & "\kickOff.vbs" & chr(34) myFile.Close '========================================================= 'The startup script will delete itself once it is launched '========================================================= wscript.echo "Startup script created"
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|