This repository gives an example on how to use the Java Native Access Library to read the stdout of a child process. In this particular example we are starting a powershell script as a child process in an specific user context and reading its output.
- Argument 0: Path to the executable
- Argument 1: Commands that should be passed to the process
- Argument 2: Username
- Argument 3: Password
- (Optional) Argument 4: Domain (local if null)
Parameters:
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
" -ExecutionPolicy Bypass -File C:\\git\\JNAReadChildOutput\\script1.ps1 -ComputerName www.google.de"
"cnorris"
"Norris1940"
https://github.com/java-native-access/jna
https://www.rgagnon.com/javadetails/java-start-process-as-another-user-using-jna.html