Changing windows user in Java

后端 未结 1 1505
走了就别回头了
走了就别回头了 2021-01-26 07:36

Is it possible to set a different windows user with Java? I have following issue:

My application executes written program as admin. However, at one point I need to switc

相关标签:
1条回答
  • 2021-01-26 08:41

    In Linux we have su for this,

    I am not sure about windows but this blog seems doing it.

    further

    here is code snippet to execute native commands from java

    try {
        // Execute a command without arguments
        String command = "dir";
        Process child = Runtime.getRuntime().exec(command);
    
        // Execute a command with an argument
        command = "dir";
        child = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    }
    

    Source

    0 讨论(0)
提交回复
热议问题