tneubauertocg
asked on
VBScript fails when launched via HKLM...Run key
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\C urrentVers ion\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.shel l")
Set objFSO = Createobject("scripting.fi lesystemob ject")
strScriptPath = objFSO.getabsolutepathname ("")
strFileName = "\AppName.exe"
strCommand = chr(34) & strScriptPath & strFileName & chr(34)
objShell.Run strCommand,0
'==== end script ====
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.shel
Set objFSO = Createobject("scripting.fi
strScriptPath = objFSO.getabsolutepathname
strFileName = "\AppName.exe"
strCommand = chr(34) & strScriptPath & strFileName & chr(34)
objShell.Run strCommand,0
'==== end script ====
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER