Get Short File Name in VBScript 
Author Message
 Get Short File Name in VBScript


ChrisB typed:

Quote:
> How do I get the Short File/Path name of a file or folder in VBScript?
> If the path is C:\Program Files\My Company\My Program, is there a
> function I can call to get c:\Progra~1\MyComp~1\MyProg~1 ?

If you are dping this from WSH, FSO has everything you need.  use the ShortPath
attribute (I assume this is a file):

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFile( _
 "C:\Program Files\My Company\My Program")
WScript.Echo f.ShortPath

If you don't have them already, you are going to find the docs very useful:

http://www.*-*-*.com/
crdoc56en.exe

--
Please respond in the newsgroup so everyone may benefit.
  http://www.*-*-*.com/
 ----------
 Subscribe to Microsoft's Security Bulletins:
  http://www.*-*-*.com/



Fri, 15 Apr 2005 08:56:26 GMT  
 Get Short File Name in VBScript

Quote:

> How do I get the Short File/Path name of a file or folder in VBScript?
> If the path is C:\Program Files\My Company\My Program, is there a function I
> can call to get c:\Progra~1\MyComp~1\MyProg~1 ?

Hi

Look up the ShortPath/ShortName property in the FileSystemObject.

WSH 5.6 documentation download
http://msdn.microsoft.com/downloads/sample.asp?url=/MSDN-FILES/027/00...

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway



Fri, 15 Apr 2005 08:56:34 GMT  
 Get Short File Name in VBScript
Quick response... Thanks.. it works like a charm!


Quote:

> ChrisB typed:
> > How do I get the Short File/Path name of a file or folder in VBScript?
> > If the path is C:\Program Files\My Company\My Program, is there a
> > function I can call to get c:\Progra~1\MyComp~1\MyProg~1 ?

> If you are dping this from WSH, FSO has everything you need.  use the
ShortPath
> attribute (I assume this is a file):

> Set FSO = CreateObject("Scripting.FileSystemObject")
> Set f = FSO.GetFile( _
>  "C:\Program Files\My Company\My Program")
> WScript.Echo f.ShortPath

> If you don't have them already, you are going to find the docs very
useful:

http://download.microsoft.com/download/winscript56/Install/5.6/W982KM...
US/s

- Show quoted text -

Quote:
> crdoc56en.exe

> --
> Please respond in the newsgroup so everyone may benefit.
>  http://dev.remotenetworktechnology.com
>  ----------
>  Subscribe to Microsoft's Security Bulletins:
>  http://www.microsoft.com/technet/security/bulletin/notify.asp



Fri, 15 Apr 2005 09:00:35 GMT  
 Get Short File Name in VBScript
How do I get the Short File/Path name of a file or folder in VBScript?
If the path is C:\Program Files\My Company\My Program, is there a function I
can call to get c:\Progra~1\MyComp~1\MyProg~1 ?


Fri, 15 Apr 2005 08:37:44 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Getting short file name from long file name:

2. Converting Long File Names to Short File Names

3. Converting Long File Names to Short File Names

4. Converting Short File Names to Long File Names

5. Getting short file names instead of long filenames?

6. getting short file names

7. Getting dos short name for a file ????

8. Getting Long file names from short

9. Get long file name from short file name

10. Long File Names and Short File Names

11. Get Short File Name from Long File Name?

12. Long file names to short file name

 

 
Powered by phpBB® Forum Software