我想执行powershell cmd文件,但收到此错误消息:
System.Management.Automation.ItemNotFoundException: 'Cannot find path
'C:\Users\HP\documents\visual studio 2017\Projects\XVPNC\XVPNC\scripts\HotelMode.cmd'
because it does not exist.'
但我完全相信它存在! 我现在能做什么?或者哪里可能是个错误,拜托?
这是我的代码: (注意:即使我改变路径不包含空格,它的行为也相同!)
String scriptfilepath2 = "C:\\Users\\HP\\Documents\\Visual Studio 2017\\Projects\\XVPNC\\XVPNC\\scripts\\HotelMode.cmd";
Runspace space = RunspaceFactory.CreateRunspace();
space.Open();
space.SessionStateProxy.Path.SetLocation(scriptfilepath2);
Pipeline pipeline = space.CreatePipeline();
var cresult = pipeline.Invoke();
space.Close();