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(); - } }