I checked here and there are some topics are talking about double clikc ps1 file to run. but my situation is that I have a ps1 file opening a remote session like this:
$pw = convertto-securestring -AsPlainText -Force -String xxxxxx
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "xxxx\admin",$pw
$pc = Read-Host -Prompt "Please Enter PC name"
$session = new-pssession -computername $pc -credential $cred
Enter-PSSession $session
and i tried this way to make it double click run,
powershell.exe -command "& 'C:\A path with spaces\MyScript.ps1' -MyArguments blah"
after I entered the pc name, the console disappears....
any idea why?
您是否尝试使用-NoExit选项?
powershell.exe -NoExit -command "& 'C:\A path with spaces\MyScript.ps1' -MyArguments blah"
从Windows资源管理器启动时,此页面提供了一个批处理脚本(和其他信息),使此过程非常容易发生此不退出行为(并修复了路径是否有空格): http : //blog.danskingdom.com/修复Windows Powershell无法在其中运行其路径包含空间的脚本的问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.