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!

Code the location of the VBS file 1

Status
Not open for further replies.

TheLad

Technical User
Aug 3, 2001
3,846
GB
Guys

Please can you tell me if there is a way of coding in the location of the VBS file without specifically specifying the directory name?

I have written an app which relies on an INI file and also writes to a logfile which are both in the same location as the VBS file. I would like to write the code in the VBS file to look for the files in the same location as the VBS files

Thanks

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
[tt]sfullname=wscript.scriptfullname

'method-1
spath=createobject("scripting.filesystemobject").getparentfoldername(sfullname)
wscript.echo spath

'method-2
n=instrrev(sfullname,"\")
spath2=left(sfullname,instrrev(sfullname,"\")-1)
wscript.echo spath2

'method-3: I use for throw-away script (can fail for obvious coincidence but rarely)
spath3=replace(wscript.scriptfullname,"\" & wscript.scriptname,"")
wscript.echo spath3[/tt]
 
Thanks, method 1 works just fine.

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top