From:
c:\PROGRA~1\INSTAL~1\{1666F~1\setup.ilg
to:
C:\Program Files\InstallShield Installation Information\{1666FA7C-CB5F-
11D6-A78C-00B0D079AF64}\setup.ilg
for example.
I thought briefly that ATTRIB could help, but apparently not. ATTRIB
seems to use whatever is fed to it and/or the format of CD (short or
long). NTFS here with shortnames enabled if it makes any difference.
Hi
I know how to do it with VBScript:
http://groups.google.com/groups?selm=3D0780D8.B39B4D50%40hydro.com
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
@echo off & setlocal ENABLEEXTENSIONS
set "sn=c:\PROGRA~1\INSTAL~1\{1666F~1\setup.ilg"
set sn=%sn:\= %
for /f %%a in ('echo/%sn%') do pushd %%a\
for %%a in (%sn%) do (
for /f "tokens=4*" %%b in ('dir/x^|find/i "%%a"') do (
cd "%%c" 2>nul>nul & set "file=%%c"
)
if not defined file set "file=%%a"
)
for /f "delims=" %%a in ('cd') do set ln="%%a\%file%"
popd
echo/%ln%
goto :EOF
--
Ritchie, undo for mail
> Mark V wrote:
>
>> How can one (NTx) resolve a FQP in shortname format to the actual
>> longname format? Something I should know, but I am drawing a
>> blank.
>>
>> From:
>> c:\PROGRA~1\INSTAL~1\{1666F~1\setup.ilg
>> to:
>> C:\Program Files\InstallShield Installation
[ ]
> I know how to do it with VBScript:
>
> http://groups.google.com/groups?selm=3D0780D8.B39B4D50%40hydro.com
Thanks. I was hoping for a native (non-VBS or other) other method.
That did get me thinking though about shortcuts. It turns out the
same technique can be used with shortcut.exe
(Shortcut version 1.00)
(Copyright 2000 Marty List, Opti...@usa.net)
C:\TEMP>shortcut /A:C /F:c:\temp\test1.lnk /T:C:\PROGRA~1\INSTAL~1\{1666F~1\setup.ilg
C:\TEMP>shortcut /A:Q /F:c:\temp\test1.lnk
TargetPathExpanded=C:\Program Files\InstallShield Installation Information\{1666FA7C-CB5F-11D6-A78C-00B0D079AF64}\setup.ilg
(Same for MS shortcut.exe (W95) ver 4.0.0.951)
Which makes me wonder exactly what API or code is utilized to resolve
the "expanded" FQP. And further, if any OS supplied executables can
do the job from a cmd prompt.
Marty?
Thanks Richie.
Excellent and useful technique. A "keeper".
I'll need to study this a bit... ;-)
eh he, I was thinking that about Torgeir's script.
Shortcut.exe is not expanding SFNs to LFNs intentionally, it does call the
ExpandEnvironmentStrings() function to resolve any %...% variables for the
'TargetPathExpanded', so maybe that is a side-effect of that function. I
don't have time to test it right now.
There are some API function specifically for this:
GetLongPathName:
http://msdn.microsoft.com/library/en-us/fileio/base/getlongpathname.asp
GetShortPathName:
http://msdn.microsoft.com/library/en-us/fileio/base/getshortpathname.asp
GetFullPathName:
http://msdn.microsoft.com/library/en-us/fileio/base/getfullpathname.asp
A tool using these wouldn't be too hard to write, if no one finds one out
there then maybe I'll tackle it sometime soon.
> @echo off & setlocal ENABLEEXTENSIONS
> set "sn=c:\PROGRA~1\INSTAL~1\{1666F~1\setup.ilg"
> set sn=%sn:\= %
> for /f %%a in ('echo/%sn%') do pushd %%a\
>
> for %%a in (%sn%) do (
> for /f "tokens=4*" %%b in ('dir/x^|find/i "%%a"') do (
> cd "%%c" 2>nul>nul & set "file=%%c"
> )
> if not defined file set "file=%%a"
> )
>
> for /f "delims=" %%a in ('cd') do set ln="%%a\%file%"
> popd
> echo/%ln%
> goto :EOF
How about this instead which uses wildcards in the path so that PUSHD
(and therefore CD) gives the long path name.
@echo off
setlocal
set "sn=c:\PROGRA~1\INSTAL~1\{1666F~1\setup.ilg"
for /f "tokens=*" %%a in ('dir /b %sn%') do set ln=%%a
set sn=%sn:\=*\%
set sn=%sn::*\=:\%
pushd %sn%\..
for /f "tokens=*" %%a in ('cd') do set ln="%%a\%ln%"
echo %ln%
Garry
Now that's a keeper, thanks Garry.
Nice! Another great and even shorter solution. Thanks.
This actually came up as a question from a new user of Regina REXX on
Win32. Regina and commonly available function packages do not
resolve Long from Short paths at this time. Such a function will be
available soon. Personally I've never yet had the need but got very
curious.
BTW in a REXX Group it is stated that GetLongPathName is not
supported in NT4. FWIW.
I'd like to thank all the posters for the inventive and useful batch
(and VBS) solutions posted. Instructive and informative as I
expected.
I have a vague memory of writing these about 5 years ago, No real idea why.
I think I needed the SFN for one program and decided to do the LFN too.
http://paulsadowski.com/scripts/download.asp?fn=lfname.exe
http://paulsadowski.com/scripts/download.asp?fn=shortname.exe
c:\users\sadowski [(firecat) 11:51, Fri 10/10/2003] shortname "c:\Program
Files\ActiveDocs\Licence\5354-8671-2239-7659-8456\ActiveUser.SLS"
c:\PROGRA~1\ACTIVE~1\Licence\5354-8~1\ACTIVE~1.SLS
c:\users\sadowski [(firecat) 11:57, Fri 10/10/2003] lfname
c:\PROGRA~1\ACTIVE~1\Licence\5354-8~1\ACTIVE~1.SLS
c:\Program Files\ActiveDocs\Licence\5354-8671-2239-7659-8456\ActiveUser.SLS
Anyone wanting to use them should do some testing for bugs since I have no
real memory of using or testing them.
They work good enough for me, thanks. I found one small oddity, lfname.exe
and shortname.exe seem to handle files in use differently. Not a big deal,
but for example:
C:\>shortame c:\pagefile.sys
C:\>lfname c:\pagefile.sys
c:\pagefile.sys
Interesting. I'll have to see if I can find the source code. It's probably
archived on some CD somewhere, if I bothered to keep it all.