大概像这样- #@&cls&powershell "type '%~0'|out-string|iex"&pause&exit
- $Runspace = [runspacefactory]::CreateRunspace()
- $PowerShell = [powershell]::Create()
- $PowerShell.runspace = $Runspace
- $Runspace.Open()
- [void]$PowerShell.AddScript({
- while(1){
- if($env:a -ne $null){break}
- sleep 1
- }
- start cmd "/k echo $env:a"
- })
- $AsyncObject = $PowerShell.BeginInvoke()
- while(1){
- $env:a+=[console]::readkey(1).keychar
- }
复制代码
|