Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help running vbscript when in PATH 1

Status
Not open for further replies.

kungfusnwbrdr

Technical User
Sep 26, 2007
6
US
Okay, so I will admit that I'm a VBScript newb at this point. I've written a wrapper script to run another program for me and to create a lock file while that program is running to prevent other users from accessing the program at the same time.

I've compiled the VBScript into an EXE and it grabs the path to the program from an INI file located in the same directory as the VBScript in EXE form. The VBScript EXE is in its own directory, which is in the PATH before the actual program it is running. When the user launches the program from the shortcuts it works just fine. If the user attempts to run the program from the Run window or a command window, however, it can't find the INI file.

I believe what is happening is the PATH where the command is run from is somehow being passed to the script. I could specify the absolute path in the script, but I wanted to avoid that if possible to make it as portable in the EXE form as possible (hence the INI file). Is there an easy way for the VBScript in EXE form to find its own directory and locate the INI file in that path and to place the lock file in the same path?
 
I suppose it depends on what application you're using to put your VBScript into an EXE and what limitations that product may have. What are you using to do this?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Have a look at the WScript.ScriptFullName property and the InStrRev function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You may try a simple script to simply echo out what PHV suggested in a msgbox to see if vbs2exe returns a proper path.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Okay, so I tried a simple script to echo the path from the original VBS script and the compiled EXE file. The original VBS script returns the corret path to the script, while the complied EXE returns back the user's Temp directory under their profile.

Hmmm...
 
So I'm thinking at this point that I might try to setup the paths as registry entries and have the script go and grab the registry keys so it knows where to look for the INI file and where to place the lock file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top