From 6e6e8dfd6ce9a2c2a7c93fd49c2d649820a2e561 Mon Sep 17 00:00:00 2001 From: profesorfalken Date: Thu, 7 Feb 2019 16:45:52 +0100 Subject: [PATCH] Use -NoProfile flag ans remove the patch used to clear buffer --- .../com/profesorfalken/jpowershell/PowerShell.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/com/profesorfalken/jpowershell/PowerShell.java b/src/main/java/com/profesorfalken/jpowershell/PowerShell.java index 518fc4f..30e65ec 100644 --- a/src/main/java/com/profesorfalken/jpowershell/PowerShell.java +++ b/src/main/java/com/profesorfalken/jpowershell/PowerShell.java @@ -137,7 +137,7 @@ private PowerShell initalize(String powerShellExecutablePath) throws PowerShellN //Start powershell executable in process if (OSDetector.isWindows()) { pb = new ProcessBuilder("cmd.exe", "/c", "chcp", codePage, ">", "NUL", "&", powerShellExecutablePath, - "-ExecutionPolicy", "Bypass", "-NoExit", "-Command", "-"); + "-ExecutionPolicy", "Bypass", "-NoExit", "-NoProfile", "-Command", "-"); } else { pb = new ProcessBuilder(powerShellExecutablePath, "-nologo", "-noexit", "-Command", "-"); } @@ -164,9 +164,6 @@ private PowerShell initalize(String powerShellExecutablePath) throws PowerShellN // Init thread pool. 2 threads are needed: one to write and read console and the other to close it this.threadpool = Executors.newFixedThreadPool(2); - //Clean output stream to avoid init profile messages - clearOutput(); - //Get and store the PID of the process this.pid = getPID(); @@ -474,9 +471,4 @@ private long getPID() { return -1; } - - //Call null command in order to clear the output stream - private void clearOutput() { - executeCommand("$null").getCommandOutput(); - } }