太原网站建设方案书,wordpress主页空白页,深圳网站建设公司哪里有,大兴区网站建设公司一、目的
1.powershell能简单写一些小脚本#xff0c;不需要exe开发这么笨重。
2.在windows实现某个特定功能#xff0c;做成一个exe能方便查看管理。 二、实现
1.C# code 运行结束加入返回值
Environment.ExitCode 1; //自定义数字
2.powershell 调用并获取
需要增加…一、目的
1.powershell能简单写一些小脚本不需要exe开发这么笨重。
2.在windows实现某个特定功能做成一个exe能方便查看管理。 二、实现
1.C# code 运行结束加入返回值
Environment.ExitCode 1; //自定义数字
2.powershell 调用并获取
需要增加 -PassThru
$proc Start-Process test.exe -ArgumentList testarg1 testarg2 -Wait -PassThru
$proc.ExitCode# ArgumentList 可以使用变量
$paramList(testarg1, testarg2)
注意
1.使用 Start-Process运行当前窗口是test.exe
2.如果不想影响窗口焦点获取不使用Start-Process直接运行。代价就是不能获取返回值考虑exe文件内部生产txt log 然后powershell通过读取log来判断结果。 参考(2条消息) Powershell Start-Process 后被调用程序的返回值_Vizer0-0的博客-CSDN博客https://blog.csdn.net/z1012178837/article/details/103716847