How to get the long file name in bat file?

I am trying to add a new action to the association/file types in windows and I am calling a bat file for that action,but %1 parameter which I am referring inside the bat file is giving only the DOS file name ( the one with tilde symbol) instead of long file name.Is there any work around to get the long file name??

As I mentioned,I am attaching this bat file as a action command for a particular file type so when I am right clicking on those type I get that action.So I don't really pass this file name directly rather windows explorer does this.

Actually what I am doing is invoking a URL with this file name as a parameter and the url is a CGI script which manipulates the file at the server.

my bat file has something like this
start http://myserver:8100/rep/filegen?"%1"

Everything works but I get the DOS name instead of long name...Any clues??
Thanks
itmenonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pbarretteCommented:
Hi itmenon,

This is what I tested on Win98. I created my own association for .PB files using the following for "Open Program With...":
C:\TEMP\PATHS.BAT "%1"

Then, I created the "C:\TEMP\PATHS.BAT" file which consists of the following:
:: -----PATHS.BAT------
@ECHO OFF
SET FILEPATH=
CD %1\..
DIR /B %1 > C:\TEMP\FILEPATH.TXT

ECHO @PROMPT SET FILEPATH=>C:\TEMP\TEMP1.BAT
TYPE C:\TEMP\FILEPATH.TXT >> C:\TEMP\TEMP1.BAT
ECHO @PROMPT $H >> C:\TEMP\TEMP1.BAT
command /C C:\TEMP\TEMP1.BAT >> C:\TEMP\TEMP2.BAT
CALL C:\TEMP\TEMP2.BAT > NUL

DEL C:\TEMP\FILEPATH.TXT
DEL C:\TEMP\TEMP1.BAT
DEL C:\TEMP\TEMP2.BAT

START IEXPLORE "http://www.google.com/search?q=%%22%FILEPATH%%%22"
:: -----PATHS.BAT------

I tested this against a file called:
"This is a long filename.pb"

When I double-click the file, it opens a google page with the following URL:
http://www.google.com/search?q=%22This%20is%20a%20long%20filename.pb%22

So I'm having no problems with Win98 passing the longname to my batchfile.

Hope this helps,
pb
0
itmenonAuthor Commented:
Hi pb,

When I am running paths.bat file gets following messages::
Bad command or file name
Out of environment space
Bad command or file name

Bat file is failing on this step ::
command /C C:\TEMP\TEMP1.BAT >> C:\TEMP\TEMP2.BAT
it is giving me ::Bad command or file name.

Any idea??

Thanks
0
pbarretteCommented:
Hi itmenon,

I forgot to mention that it will return 1 or 2 instances of "Bad command or filename", but it still works fine.

This is because the TEMP1.BAT file contains lines which are run as commands, but are not actual commands. It is used only to get the filename into a variable.

If you are getting an "Out of environment space" error, then you need to be sure that you are running the batchfile in Win9x. It will not work as written in NT/2K/XP. To make it work in those OS's, you need to change the "COMMAND /C" to "CMD /C".

If none of those things helps, then you may need to change the "START IEXPLORE" to "START C:\PROGRA~1\INTERN~1\IEXPLORE.EXE"

pb
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
itmenonAuthor Commented:
Perfect on Win98!!!

I had to increase the environment space..!!!

thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.