VBScript fails when launched via HKLM...Run key
Posted on 2013-05-13
Hello - I am at a loss and am hoping someone might know how to resolve the issue I am having. The script below is being used to launch an application .exe - hiding the CMD window from the users. It is being triggered from the registry key "HKLM\Software\Microsoft\CurrentVersion\Run". This is so that it runs when anyone logs on.
The script works perfectly well as admin or non-admin user when launched manually. However, it always fails on the "objShell.Run" line when the registry key is used stating that it cannot find the file specified. I have attempted a 5 second timeout and that did not help either.
The .exe and the .vbs are located in the same sub-directory of "C:\Program Files".
Any ideas would be greatly appreciated!!!
'==== start script ====
Set objShell = CreateObject("wscript.shell")
Set objFSO = Createobject("scripting.filesystemobject")
strScriptPath = objFSO.getabsolutepathname("")
strFileName = "\AppName.exe"
strCommand = chr(34) & strScriptPath & strFileName & chr(34)
'==== end script ====