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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb directory to use

Status
Not open for further replies.

Briandr

MIS
Jul 11, 2003
177
US
Hi,

I am trying to extract a vbscript and batch file from an exe created with W7's Iexpress. Iexpress does not tell you the default location files are extracted to. I think its a temp directory of some kind. Problem I am having is the vb needs to know where the batch file is in order to run it. Is there a way of telling vb to use the currect directory so that way it could find and run the batch?

Thanks.
 
The current directory where IExpress would have dumped both the batch and vbscript. That way the vbscript knows where to find the batch.
 
This is what I have thus far. As you can see I am not actually setting a path in the run line as I don't know where the files are. I think they are in a temp folder that IExpress extracted them to.

Set objShell = WScript.CreateObject("WScript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
strCurDir = objFSO.GetParentFolderName(WScript.ScriptFullName)
objShell.Run("AltirisCleanup.bat"), 0, True

Maybe what I am trying to do can't be done?
 
...What good is the current directory if you can't find the file that's in it. Furthermore, once you find the file, you don't need the current directory. As far as I can tell, you'd only need the current directory if a vbs was automatically executed...

You can look in the Environmental Variables to see if IExpress added its own entry or if the temp dir is in the %path% variable. Or search your registry for IExpress. Perhaps the temp dir is a reg entry.

-Geates

 
Briandr,

The way you are doing it looks correct; don't specify a path for the batch file, assume the same folder as the script. If you're sure you added both the vbs and batch file to the "Packaged Files" section if the iexpress wizard, maybe add some error trapping?


Code:
Set objShell = WScript.CreateObject("WScript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
strCurDir = objFSO.GetParentFolderName(WScript.ScriptFullName)
[COLOR=#EF2929]on error resume next[/color]
objShell.Run("AltirisCleanup.bat"), 0, True
[COLOR=#EF2929]if err.number <> 0 then
   wscript.echo "Got err#" & err.number & " when running the batch file"
else
   wscript.echo "Batch file was executed"
end if
on error goto 0[/color]
 
Hi,

Thanks guys. The vb would be automatically executed after the files extract from the exe created by IExpress.

Added error trapping and got this.

Output from the error was -2147024894
 
When I run the file (inside or outside the compiled IExpress) vbscript throws an error about the file not being found. The files are both in the same directory. Forgot to mention this above.
 
What happens when you put the .vbs and the .bat in the same folder, and double-click the .vbs file?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top