1

Windows PowerShell を使用してデスクトップ ショートカットを作成する方法を学習しようとしています。これにより、会社のコンピューターの展開にいくつかのショートカットを含むスクリプトを追加できます。$Shortcut.Save() コマンドに到達するまで、すべてがうまく機能します。

    PS C:\Windows\system32> $TargetApp = "C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"
    PS C:\Windows\system32> $WshShell = New-Object -ComObject WScript.Shell
    PS C:\Windows\system32> $Shortcut + $WshShell.CreateShortcut("$Home\Desktop\Firefox.lnk")
    PS C:\Windows\system32> $Shortcut.TargetPath = $TargetApp
    PS C:\Windows\system32> $Shortcut.Save()

私はテストとしてfirefoxを使用しています。最後の行を実行すると、エラーが発生します。

"Exception calling "Save" with "0" arguments(s): "Unable to save shortcut "C:\Desktop\Firefox.lnk".""

コードは他の人でも機能するようですが、私のコンピューターの設定でしょうか?

4

0 に答える 0