<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBScript: получение длинного имени файла/папки по короткому имени]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=4926</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=4926&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBScript: получение длинного имени файла/папки по короткому имени».]]></description>
		<lastBuildDate>Thu, 09 Sep 2010 16:27:33 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBScript: получение длинного имени файла/папки по короткому имени]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=39349#p39349</link>
			<description><![CDATA[<p>Получение длинного имени на основе короткого можно оформить функцией (на основе изложенного выше):<br /></p><div class="codebox"><pre><code>Option Explicit

WScript.Echo GetLongPath(&quot;C:\PROGRA~1\WINDOW~1\ACCESS~1&quot;)
WScript.Echo GetLongPath(&quot;C:\PROGRA~1\WINDOW~1\ACCESS~1\wordpad.exe&quot;)

&#039; Пример с ошибкой в имени (раскомментировать)
&#039; WScript.Echo GetLongPath(&quot;C:\PROGRA~1\WINDOW~1\ACCESS~1\wodpad.exe&quot;)

WScript.Quit 0
&#039;=============================================================================

&#039;=============================================================================
Function GetLongPath(strShortPath)
    Dim strShortFolder
    Dim strShortFile
    
    Dim boolIsFolder
    
    Dim objShell
    Dim objFolder
    Dim objFolderItem
    
    With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
        If .FolderExists(strShortPath) Then
            boolIsFolder   = True
            
            strShortFolder = strShortPath
        Else
            If .FileExists(strShortPath) Then
                boolIsFolder   = False
                
                strShortFolder = .GetFile(strShortPath).ParentFolder
                strShortFile   = .GetFile(strShortPath).Name
            Else
                Err.Raise &amp;H800A0035, WScript.ScriptFullName &amp; &quot;::GetLongPath(strShortPath)&quot; , &quot;File or folder [&quot; &amp; strShortPath &amp; &quot;] not found&quot;
            End If
        End If
    End With
    
    Set objShell  = WScript.CreateObject(&quot;Shell.Application&quot;)
    Set objFolder = objShell.Namespace(strShortFolder)
    
    If Not objFolder Is Nothing Then
        If boolIsFolder Then
            GetLongPath = objFolder.Self.Path
        Else
            Set objFolderItem = objFolder.ParseName(strShortFile)
            
            If Not objFolderItem Is Nothing Then
                GetLongPath = objFolderItem.Path
                
                Set objFolderItem = Nothing
            End If
        End If
        
        Set objFolder = Nothing
    End If
    
    Set objShell  = Nothing
End Function
&#039;=============================================================================</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 09 Sep 2010 16:27:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=39349#p39349</guid>
		</item>
		<item>
			<title><![CDATA[VBScript: получение длинного имени файла/папки по короткому имени]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=39347#p39347</link>
			<description><![CDATA[<p>Способ получения короткого имени объекта файловой системы <em>[как правило, полного пути — обычно требуется именно полный путь, а не только имя]</em> по имеющемуся обычному, длинному имени наличествует в Windows Script Host изначально в объекте <a href="http://www.script-coding.com/WSH/FileSystemObject.html">Scripting.FileSystemObject</a>.</p><p>Для папки:<br />* короткое имя — метод <a href="http://www.script-coding.com/WSH/FileSystemObject.html#6.2.10.">.ShortName</a>;<br />* полный путь — метод <a href="http://www.script-coding.com/WSH/FileSystemObject.html#6.2.11.">.ShortPath</a>.</p><p>Для файла аналогично:<br />* короткое имя — метод <a href="http://www.script-coding.com/WSH/FileSystemObject.html#5.2.9.">.ShortName</a>;<br />* полный путь — метод <a href="http://www.script-coding.com/WSH/FileSystemObject.html#5.2.10.">.ShortPath</a>.</p><br /><p>Обратный же процесс — получение длинного имени объекта файловой системы по имеющемуся короткому имени в Windows Script Host, к сожалению, отсутствует. Предлагается следующий способ определения длинного имени посредством Проводника:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim objShell
Dim objFolder
Dim objFolderItem

&#039; C:\PROGRA~1\WINDOW~1\ACCESS~1\wordpad.exe
&#039; C:\Program Files\Windows NT\Accessories\wordpad.exe

Set objShell  = WScript.CreateObject(&quot;Shell.Application&quot;)
Set objFolder = objShell.Namespace(&quot;C:\PROGRA~1\WINDOW~1\ACCESS~1&quot;)

If Not objFolder Is Nothing Then
    &#039; Длинное имя [полный путь] папки
    WScript.Echo objFolder.Self.Path
    
    Set objFolderItem = objFolder.ParseName(&quot;wordpad.exe&quot;)
    
    If Not objFolderItem Is Nothing Then
        &#039; Длинное имя [полный путь] файла
        WScript.Echo objFolderItem.Path
        
        Set objFolderItem = Nothing
    End If
    
    Set objFolder = Nothing
End If

Set objShell  = Nothing

WScript.Quit 0</code></pre></div><p>Автор идеи — <strong>kefi</strong>.</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 09 Sep 2010 15:47:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=39347#p39347</guid>
		</item>
	</channel>
</rss>
