I'm trying to use Process and ProcessBuilder to execute a ps1 file through powershell. I'm struggling with the entire thing and cant even get the powershell.exe to run. Ive tried :
// Wont Run
// Defined specific path for powershell - trying to simply run the exe file
ProcessBuilder pb = new ProcessBuilder("C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe");
Process p = pb.start();
I've look at Running Powershell from Java and Run a powershell on a remote machine using JAVA trying to implement methods from these examples but I dont understand why mine wont even run an instance of powershell.
I do eventually want to incorporate running ps1 files through here but I need to walk before I can run.
Also, I have checked Task Manager and it IS running as a process.
Could anyone point me in the right direction as to why this wont even run ?
Thanks in advance
ProcessBuilder pb = new ProcessBuilder("C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -Command \"New-Item c:\imadethis.txt -type file\"");