I am running a few powershell scripts from within java, i have completed my program but now i am unsure how to package it up into an executable .jar, while still being able to use the scripts. i have placed the scripts inside the project file (at the same level as the src folder)
String[] commands1 = {"powershell.exe", "Set-Variable", "-Name \"address\" -Value \""+javaAddress+"\";", "C:\\Users\\--\\Documents\\ieAutomate.ps1\" "};
&
String runScan = "powershell.exe \"C:\\Users\\--\\Documents\\ipScan.ps1\" " ;
Process scanProcess = Runtime.getRuntime().exec(runScan);
I am aware that .class.getResourceAsStream("ipScan.ps1")
could potentially work - but how can i use this as a string for the second part of the runScan
string?
I also am unsure how to specify filepath for a FileWriter too.
writer2or32Port = new FileWriter("C:\\Users\\--\\Documents\\serials\\2or32Port.csv");
buffer2or32Port = new BufferedWriter(writer2or32Port);`
ideally i can just use something like %USERNAME% or %USERPROFILE% to any users desktop
writer2or32Port = new FileWriter("%USERPROFILE%\\Desktop\\2or32Port.csv");
However im getting file not found exceptions. Any help would be appreciated.
Thanks