3
私はpowershellで以下のコードを使ってショートパスを取得しようとしています。一部のフォルダでは機能します。いくつかのためには動作しません。powershellを使ってショートパスを取得
$a = New-Object -ComObject Scripting.FileSystemObject
$f = $a.GetFile("C:\Program Files\Internet Explorer")
$f.ShortPath
フォルダが利用可能であるが、私は以下のエラーを取得:
$a = New-Object -ComObject Scripting.FileSystemObject
$f = $a.GetFile("C:\Program Files\Internet Explorer\iexplore.exe")
$f.ShortPath
$f = $a.GetFolder("C:\Program Files\Internet Explorer")
$f.ShortPath
Outpの:
Exception calling "GetFile" with "1" argument(s): "Exception from HRESULT: 0x800A0035 (CTL_E_FILENOTFOUND)"
At C:\Misc\GetShortPath.ps1:4 char:1
+ $f = $a.GetFile("C:\Program Files\Internet Explorer")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
誰かが
ありがとうJosefZ。それは私の側から、私がフォルダを探しているときにGetFileを使うのはばかげた間違いでした。 – user3180704