1
I have a program which I install using an NSIS script. The final step in the installer is to write to the registry Run key and have the program run on startup. I've confirmed that under
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
exists the key
MyCompany Program - C:\MyCompany\Program\launch.vbs
I've tried the key with and without quotes but there was no impact. I have confirmed the registry is reading from CurrentVersion\Run by adding
Notepad - C:\windows\notepad.exe
and Notepad now launches at startup. The launch.vbs script is a one liner to launch a script without the cmd.exe window:
'HideBat.vbs from https://superuser.com/questions/140047/how-to-run-a-batch-file-without-launching-a-command-window
CreateObject("Wscript.Shell").Run "cmd /c " & chr(34) & "C:\MyCompany\Program\run.cmd " & chr(34), 0, True
I've confirmed calling launch.vbs from an explorer window or from cmd.exe works as I expect (launching my program). msconfig confirms that C:\MyCompany\Program\launch.vbs is listed in the startup tab. The security tab of File Properties indicates all users should have read & execute privileges. Ditto the run.cmd actually getting called.
At this point I'm at a loss as to why my program isn't being launched, and I can't figure an efficient way to debug it.
System is Windows 7 Professional 64-bit.
To run a .vbs you need to call
cscriptI think. Putcscript your_script.vbsin the "Run" and see if that works. Falling that you'll have to write a .bat to call the same thing. – Kinnectus – 2015-03-10T20:34:47.650Putting cscript in front of it, I see a very brief cmd.exe window which immediately terminates. Doesn't actually start the program. – guest – 2015-03-10T20:59:57.390
don't use cscript, but wscript instead. cscript makes the script work through a console window, causing you to always see one, and thats exactly what you want to avoid. putting a ' in front of a like makes you comment out a line. Do so on the line in your .vbs script. Add a new line and write:
msgbox "test". now run the .vbs script and see if the msgbox pops up. Then reboot and see if it does too. This will tell you if the script loads or not, and where to look for the problem. – LPChip – 2015-03-10T21:12:40.250Adding a msgbox "STARTING" before the call and a msgbox "ENDING" after the call, and I confirmed that the script is being called. Will have to figure out why running via startup isn't working, but calling the script afterwards is. Can cscript.exe be configured to print commands to stdout (like bash's -x)? – guest – 2015-03-10T21:25:52.617
I also notice your putting it in the 32-bit registry node, why? That could make a difference. – Ramhound – 2015-03-10T21:36:48.810
Not intentionally - its a 32 bit installer running in 32 bit cmd.exe; the Wow6432Node where it ends up because neither program is 64 bit. Shouldn't make a difference, however. – guest – 2015-03-10T21:39:17.437