Solved

VBScript fails when launched via HKLM...Run key

Posted on 2013-05-13
2
412 Views
Last Modified: 2013-05-14
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)

objShell.Run strCommand,0

'==== end script ====
0
Comment
Question by:tneubauertocg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 39163303
Hi, if AppName.exe is in the same folder as the script, then use

strScriptPath       = objFSO.GetParentFolderName(WScript.ScriptFullName)

Regards,

Rob.
0
 

Author Closing Comment

by:tneubauertocg
ID: 39164770
Worked like a charm - thank you!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question