我正在C#中工作,用於清理Windows 10開始菜單並分配自定義佈局的程序。爲此,我需要從powershell運行一個命令,並且在運行時遇到錯誤。運行過程中的Powershell錯誤
我是如何完成這項任務的。
我開始C:\ \ \ powershell.exe和傳球的-command參數:。進口StartLayout -LayoutPath C:\ StartMenu.xml -MountPath C:\
Process process = new Process();
process.StartInfo.FileName = @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe";
process.StartInfo.Arguments = @" -command Import-StartLayout -LayoutPath C:\StartMenu.xml -MountPath C:\";
process.Start();
以下是錯誤我收到:
Import-StartLayout : The term 'Import-StartLayout' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:1
+ Import-StartLayout -LayoutPath C:\StartMenu.xml -MountPath C:\; Start ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Import-StartLayout:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
任何想法,爲什麼CMD或PowerShell中不會採取進口StartLayout的外部cmdlet的?
哪個版本的windows是測試電腦 –
PS腳本是否從PowerShell CLI界面運行? – zwork
「*我如何完成任務*」 - 那個位在哪?你如何運行PowerShell? – TessellatingHeckler