batch file "where am i?"

K

Kevin

I'm trying to create a "mobile" batch file that calls a vbscript (I need to
run the vbscript from CSCRIPT, but I want the user to be able to click on a
file from explorer (which would normally run it with wscript...))

Anyway, I'm looking for a solution to set an environment variable to the
path of the location of the batch file - NOT the "current directory"
context, but the FOLDER PATH to the .BAT file.

Any suggestions?
 
K

Kevin

Sweet! Thanks.


--
----------------------------------------------------
The views expressed here are my own
and not of my employer.
----------------------------------------------------
Dean Wells said:
I may be misunderstanding your requirement but try this -

@echo %~p0

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


Kevin said:
I'm trying to create a "mobile" batch file that calls a vbscript (I need to
run the vbscript from CSCRIPT, but I want the user to be able to click on a
file from explorer (which would normally run it with wscript...))

Anyway, I'm looking for a solution to set an environment variable to the
path of the location of the batch file - NOT the "current directory"
context, but the FOLDER PATH to the .BAT file.

Any suggestions?

--
 
D

Dean Wells [MVP]

Uncertain I'm afraid but I would guess yes ... someone with more NT4
experience than I may well be able to give you an accurate answer.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


Karl Bernard said:
Does this work in NT 4.0 environments as well? (I have a script that is run
on a variety of NT-based platforms)

Thanks,

Karl

Dean Wells said:
I may be misunderstanding your requirement but try this -

@echo %~p0

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


Kevin said:
I'm trying to create a "mobile" batch file that calls a vbscript
(I
need to
run the vbscript from CSCRIPT, but I want the user to be able to
click
on a
file from explorer (which would normally run it with wscript...))

Anyway, I'm looking for a solution to set an environment variable
to
the
path of the location of the batch file - NOT the "current directory"
context, but the FOLDER PATH to the .BAT file.

Any suggestions?

--
 
C

Clay Calvert

Uncertain I'm afraid but I would guess yes ... someone with more NT4
experience than I may well be able to give you an accurate answer.

Dean

Yes, it does. See "For /?" for the syntax.

FYI: %~dp0 will include the drive letter as well.

Clay Calvert
(e-mail address removed)
Replace "W" with "L"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top