0

I am creating a simple app for our users that checks if a specific user is active on a PC and returns the result.

The app consists of two parts, one will be distributed to our seniors who can set their status (meeting, break etc.), the other will be used by our juniors to check if the senior is available for helping out at any given time.

It works by running a PowerShell script which pings a PC, checks the user and stores the result in a (accessible) hashtable on a network share.

Both apps work perfectly when used by a admin, but problems arise when a normal user tries the same, it just does not run the required PS scripts.

I am 99% sure that user rights are the culprit here but I am struggling to find a simple enough solution.

I have also setup a GPO (checked the PC-s via gpresult and rsop.msc) that should theoretically allow it:

Computer Configuration > Policies > Administrative Templates > Windows Components > Windows PowerShell -- Turn on script execution -- Allow all scripts. (Unsafe, but it is for testing purposes :))

The Java code snippet that runs the script looks like this:

run_script(String path) throws IOException {

String command = String.format("powershell.exe -executionpolicy bypass -file %s",path);

String result;

Process powerShellProcess = Runtime.getRuntime().exec(command);
powerShellProcess.getOutputStream().close();

BufferedReader brd= new BufferedReader(new InputStreamReader(
powerShellProcess.getInputStream()));

while ((result= brd.readLine()) != null) {
System.out.println(result);
              }

brd.close();

BufferedReader err= new BufferedReader(new InputStreamReader(
powerShellProcess.getErrorStream()));

while ((line = err.readLine()) != null) {
System.out.println(result);
              }
err.close();

}

Just to repeat the important part, everything runs fine when a admin runs the app, only normal users cannot get the expected result.

And finally, my question :)

Is it possible to run code like that without admin rights on a remote PC through a Java app and are there any alternatives for getting the result I want (ping PC, check user, return result without using PowerShell)?

Thank you in advance for any suggestions and advice!

ckifer
  • 190
  • 1
  • 3
  • 14

0 Answers0