安装powershell ISE
设置权限
解决方案
1.管理员打开PowerShell
2. 执行Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
运行脚本
自定义函数,
function start_service([string]$Name,$p,$r)
{
$NewTab = $psISE.PowerShellTabs.Add()
$NewTab.DisplayName = $Name
# Wait until the tab is ready
while (-not $NewTab.CanInvoke) {
Start-Sleep -m 100
}
$NewTab.Invoke($p)
# Wait until the tab is ready
while (-not $NewTab.CanInvoke) {
Start-Sleep -m 100
}
$NewTab.Invoke($r)
}
start_service "控制台程序1" {cd "G:\CoreTestConsoleApp1\CoreTestConsoleApp1";cls;} {dotnet run}
start_service "控制台程序2" {cd "G:\CoreTestConsoleApp1\CoreTestConsoleApp1";cls;} {dotnet run}