Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FQ longnamepath from shortnamepath?

3 views
Skip to first unread message

Mark V

unread,
Oct 9, 2003, 10:27:28 AM10/9/03
to
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 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.

Torgeir Bakken (MVP)

unread,
Oct 9, 2003, 11:17:32 AM10/9/03
to
Mark V wrote:

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


Ritchie

unread,
Oct 9, 2003, 12:34:10 PM10/9/03
to
"Mark V" <notv...@invalid.nul> wrote in message news:Xns940F6A6225...@207.46.248.16...

> From:
> c:\PROGRA~1\INSTAL~1\{1666F~1\setup.ilg
> to:
> C:\Program Files\InstallShield Installation Information\{1666FA7C-CB5F-
> 11D6-A78C-00B0D079AF64}\setup.ilg

@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

unread,
Oct 9, 2003, 12:49:44 PM10/9/03
to
Torgeir Bakken (MVP) wrote in news:3F857C0C...@hydro.com:

> 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?

Mark V

unread,
Oct 9, 2003, 1:06:42 PM10/9/03
to
Ritchie wrote in news:bm42m4$ii7m4$1...@ID-156657.news.uni-berlin.de:

Thanks Richie.
Excellent and useful technique. A "keeper".
I'll need to study this a bit... ;-)


Ritchie

unread,
Oct 9, 2003, 2:28:02 PM10/9/03
to
"Mark V" <notv...@invalid.nul> wrote in message news:Xns940F856159...@207.46.248.16...

> 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.

Marty List

unread,
Oct 9, 2003, 4:00:36 PM10/9/03
to

"Mark V" <notv...@invalid.nul> wrote in message
news:Xns940F828088...@207.46.248.16...

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.

Garry Deane

unread,
Oct 9, 2003, 9:34:38 PM10/9/03
to
On Thu, 9 Oct 2003 17:34:10 +0100, "Ritchie"
<qiournvdlirh...@hotmail.com> wrote:

> @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

Ritchie

unread,
Oct 10, 2003, 2:20:27 AM10/10/03
to
"Garry Deane" <garrydeane_at_yahoo.com.au> wrote in message news:3f860b0b...@192.168.0.2...

> How about this instead which uses wildcards in the path so that PUSHD
> (and therefore CD) gives the long path name.

Now that's a keeper, thanks Garry.

Mark V

unread,
Oct 10, 2003, 10:09:35 AM10/10/03
to
Garry Deane wrote in news:3f860b0b...@192.168.0.2:

Nice! Another great and even shorter solution. Thanks.

Mark V

unread,
Oct 10, 2003, 10:14:57 AM10/10/03
to
Marty List wrote in
news:bm4ep6$ig3f8$1...@ID-172409.news.uni-berlin.de:

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.

Paul R. Sadowski

unread,
Oct 10, 2003, 12:04:59 PM10/10/03
to
"Marty List" <Bill....@sun.com> wrote in message
news:bm4ep6$ig3f8$1...@ID-172409.news.uni-berlin.de...

>
> 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.

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.


Marty List

unread,
Oct 10, 2003, 12:54:42 PM10/10/03
to

"Paul R. Sadowski" <xp...@mailshell13.mailshell.com> wrote in message
news:eZ3tEh0j...@TK2MSFTNGP12.phx.gbl...

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

Paul R. Sadowski

unread,
Oct 10, 2003, 2:13:16 PM10/10/03
to
"Marty List" <Bill....@sun.com> wrote in message
news:bm6o8j$j89su$1...@ID-172409.news.uni-berlin.de...

>
> 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.


0 new messages