我正在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