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!

How do I capture execution path? 2

Status
Not open for further replies.

withanh

IS-IT--Management
Dec 17, 2008
221
US
I want to be able to capture the path my script is being called from. In VB6 I used app.path but that doesn't work in VBS.

Thanks!
 
WScript.Path

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Have a look at the WScript.ScriptFullName property.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Mark & PH,

Thank you both for replying.

Mark, your solution returned "C:\Windows\System32" which is the path to the cscript.exe/wscript.exe not quite what I wanted, hope you didn't misunderstand my question.

PH, that is exactly what I was looking for, thank you so much!

h
 
Whoops, I take that back PH, yours gives the name of the .vbs file, I just want the path it's residing in...I guess I can parse it out but I was hoping to be able to easily capture it.

h
 
OK, you both get stars for making me think. I'm already using FSO for writing out to a log file that I keep in the same place as the script so I thought "Hmmm, there's gotta be something there!", here's what I did to capture the path:

Code:
Set objFile = objFSO.CreateTextFile(strFileName, ForWriting, False)
strPath = objFSO.GetFile(strFileName)
 
Sorry, the Wscript.Path returns the engine path not the script path. As PHV suggested use WSCRIPT.SCRIPTFULLNAME

Code:
Path =Left(WScript.ScriptFullName,(Len(WScript.ScriptFullName)-Len(Wscript.ScriptName)))

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top