1.

Solve : How to convert short paths to long paths??

Answer»

Does anyone know of a way to convert short PATHS to long paths?
if I issue the dos command Code: [Select]ftype FirefoxHTMLMy output is:Code: [Select]FirefoxHTML=C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -requestPending -osint -url "%1" But why? The short path is valid.I really need the long path for a java program I'm working on.There is a function in Windows for that. But if you tack it into java you will have code that can not port across platforms. Which is one reason for musing java.

Maybe the quick fix is to shell out to DOS and use a VB script to convert the files names. There is a function in VB script for this. I think.Quote from: Geek-9pm on February 05, 2009, 11:33:03 PM

There is a function in Windows for that. But if you tack it into java you will have code that can not port across platforms. Which is one reason for musing java.

Maybe the quick fix is to shell out to DOS and use a VB script to convert the files names. There is a function in VB script for this. I think.

Code: [Select]@echo off
@echo set oArgs = Wscript.Arguments>"%TEMP%\LongFileName.vbs"
@echo wscript.echo LongName(oArgs(0))>>"%TEMP%\LongFileName.vbs"
@echo Function LongName(strFName)>>"%TEMP%\LongFileName.vbs"
@echo Const ScFSO = "Scripting.FileSystemObject">>"%TEMP%\LongFileName.vbs"
@echo Const WScSh = "WScript.Shell">>"%TEMP%\LongFileName.vbs"
@echo. With WScript.CreateObject(WScSh).CreateShortcut("dummy.lnk")>>"%TEMP%\LongFileName.vbs"
@echo. .TargetPath = CreateObject(ScFSO).GetFile(strFName)>>"%TEMP%\LongFileName.vbs"
@echo. LongName = .TargetPath>>"%TEMP%\LongFileName.vbs"
@echo. End With>>"%TEMP%\LongFileName.vbs"
@echo End Function>>"%TEMP%\LongFileName.vbs"

set sfn=C:\PROGRA~1\MOZILL~2\firefox.exe

for /f "Tokens=*" %%a in ( ' cscript //nologo "%TEMP%\LongFileName.vbs" %sfn% ' ) do set LFN=%%a

echo %lfn%

WOW!
This looks really hopeful.
I wish I understood it or how to use it.
I copied it and put it into a batch file and ran it but it flashed by so fast I could not see any output.
Remember I am a new B.
N.OK I looked into my \Local Settings\Temp folder and found LongFileName.vbs.
Which looks like this:
Code: [Select]set oArgs = Wscript.Arguments
wscript.echo LongName(oArgs(0))
Function LongName(strFName)
Const ScFSO = "Scripting.FileSystemObject"
Const WScSh = "WScript.Shell"
With WScript.CreateObject(WScSh).CreateShortcut("dummy.lnk")
.TargetPath = CreateObject(ScFSO).GetFile(strFName)
LongName = .TargetPath
End With
End Function
Then I copied and pasted into a HTML file like this:
Code: [Select]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>shortToLong</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<script language="VBScript" type="text/vbscript">
set oArgs = Wscript.Arguments
wscript.echo LongName(oArgs(0))
Function LongName(strFName)
Const ScFSO = "Scripting.FileSystemObject"
Const WScSh = "WScript.Shell"
With WScript.CreateObject(WScSh).CreateShortcut("dummy.lnk")
.TargetPath = CreateObject(ScFSO).GetFile(strFName)
LongName = .TargetPath
End With
End Function
</script>
</body>
</html>When I try to view in a browser I get an error (No Surprise since I don't really know what I'm doing)
I've attached a screen shot of my error.
Thanks for your help.


[attachment deleted by admin]Well I figured it out. It works!! I'm so happy.
Thank You Dias de verano!
In the command line I type:
Code: [Select]cscript LongFileName.vbs "C:/PROGRA~1/MOZILL~1\firefox.exe>vb.txtAnd sure enough the vb.txt file is written with
Code: [Select]Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Program Files\Mozilla Firefox\firefox.exe
If there was some way to suppress the writing of the first TWO lines that would be nice but not necessary.
Again Thank You!


Quote from: nubia on February 06, 2009, 10:21:36 PM
If there was some way to suppress the writing of the first two lines that would be nice but not necessary.

Incidentally, you don't need that SINGLE quote mark before the short filename.

To run a VBscript with cscript.exe, without those 2 lines, you can add the //Nologo switch after the cscript command thus:

cscript //Nologo LongFileName.vbs C:/PROGRA~1/MOZILL~1\firefox.exe>vb.txt

Alternatively, you can beforehand get cscript.exe to save the //Nologo option by doing this:

cscript //Nologo //S

Afterwards, when you run any script with cscript.exe, on the same COMPUTER system, the //Nologo option is default and need not be included in the command. However this has the disadvantage that if the command is used on another system the option may or may not have been thus saved, and therefore the output of the script is unpredictable. So you should always include the //Nologo switch when supplying the script and command to other people (or explain all of the above, whichever seems appropriate!)

To restore the default behaviour to cscript.exe:

cscript //Logo //S

Use either switch to force the desired behaviour when running a script.

Although I have used capital letters N and L in the switches, they are not case sensitive.

type cscript /? at the prompt to see full details of options.

Code: [Select]C:\>cscript //nologo //S
Command line options are saved.

C:\>cscript //logo //S
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Command line options are saved.

C:\>cscript //nologo //S
Command line options are saved.Again Thank You -You have been more than helpful.
I really appreciate the time and effort you have taken to help me.
Nubia.


Discussion

No Comment Found