jPowerShell
jPowerShell copied to clipboard
执行简单命令"get-executionpolicy",结果是Bypass,不是期望的RemoteSigned?
没明白为什么不能用字符串执行呢? InputStream is = new FileInputStream("d:/test.ps1"); byte[] b = new byte[is.available()]; int i = 0; int index = 0; //循环读取每个数据 while((i=is.read())!=-1){//把读取的数据放到i中 b[index]=(byte) i; index++; } System.out.println(new String(b)); //把字节数组转成字符串 String cmd = "cmd /c powershell "+new String(b); System.out.println(cmd); Process p = Runtime.getRuntime().exec(cmd);