模块的作者放私货,在里面用中文写了极不友好的内容。
试试用管道的方法转exe | $ps='test.ps1' | | $cs='test.cs' | | ( | | @' | | using System; | | using System.Diagnostics; | | using System.IO; | | using System.Text; | | | | class StandardOutputExample | | { | | public static void Main() | | { | | using (Process p = new Process()) | | { | | byte[] psc = new byte[] { | | '@ +(([System.Text.Encoding]::UTF8.GetBytes((gc $ps) -join "`r`n")|%{'0x'+$_.tostring('X2')})-join',')+ @' | | }; | | p.StartInfo.FileName = "powershell.exe"; | | p.StartInfo.UseShellExecute = false; | | p.StartInfo.RedirectStandardOutput = true; | | p.StartInfo.RedirectStandardInput = true; | | p.Start(); | | StreamReader r = p.StandardOutput; | | StreamWriter w = p.StandardInput; | | w.WriteLine("cd "+AppDomain.CurrentDomain.BaseDirectory); | | w.WriteLine(Encoding.UTF8.GetString(psc)); | | Console.WriteLine(r.ReadToEnd()); | | p.WaitForExit(); | | Console.ReadLine(); | | } | | } | | } | | '@ | | )|sc $cs | | C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe $csCOPY |
|