I have a PS script that I need to run without the user having to open powershell - the easiest thing in my mind is writting an application or .bat file that will run the PS script. However I cant get the script to run using any other languages.
Ive tried using java but it doesnt run the script, neither does C# or a batch command. Ill attach the batch below as that seems to be the easier method im just not sure why it doesnt work - theres no error messages it just doesnt work.
Edit** The Powershell script is below and can be run. I need a third party application that will run the script.
$wshell = New-Object -ComObject Wscript.Shell
$Output = $wshell.Popup("Select a Folder that you want to Analyze
Please be aware the larger the folder size the Longer it will take to Generate")
@echo off
powershell.exe -ExecutionPolicy Unrestricted -Command "'I:\TestScript\FolderInformation.ps1'"
TIMEOUT /T 10
I just need to be able to run the script by launching a single application as its for users who wont know to use ISE or any other PS applications.
Any application or script ive used thus far doesnt work besides just using ISE to run it.
***** Java Code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PowerShellJavaDemo {
public static void main(String[] args) throws IOException {
String line;
String command = "powershell.exe & \"I:\\testingscript\"";
Process powerShellProcess = Runtime.getRuntime().exec(command);
powerShellProcess.getOutputStream().close();
BufferedReader stdout = new BufferedReader(new InputStreamReader(powerShellProcess.getInputStream()));
while ((line = stdout.readLine()) != null) {
System.out.println("Output: " + line);
}
stdout.close();
BufferedReader stderr = new BufferedReader(new InputStreamReader(powerShellProcess.getErrorStream()));
while ((line = stderr.readLine()) != null) {
System.out.println("Output: " + line);
}
stderr.close();
}
}