Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBScript fails when launched via HKLM...Run key

Posted on 2013-05-13
2
Medium Priority
?
413 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 2000 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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

705 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