Run a program or script as another user, there is sudo -u in Unix-like, but there is no sudo -u command in Windows, the nearest equivalent is runas command.
*But can't pipe a password into runas, because it requests the password from the terminal, not from stdin.* So, I have to reimplement ProcessImpl.java, ProcessEnvironment.java and ProcessBuilder.java for Windows. First, for Windows, I will reimplement it by JNA: ProcessBuilder.java: *copy and rewrite it* ProcessEnvironment.java: *rewrrite it by JNA* private static native String environmentBlock(); ProcessImpl.java: *rewrrite it by JNA* private static native int getStillActive();private static native int getExitCodeProcess(long handle);private static native void waitForInterruptibly(long handle);private static native void waitForTimeoutInterruptibly(long handle, long timeout);private static native void terminateProcess(long handle);private static native boolean isProcessAlive(long handle);private static synchronized native long create(String cmdstr, String envblock, String dir, long[] stdHandles, boolean redirectErrorStream)private static native long openForAtomicAppend(String path) throws IOException;private static native boolean closeHandle(long handle); Finally, I will create new file in ds, like ProcessBuilderForWin32.java, ProcessEnvironmentForWin32.java, ProcessImplForWin32.java So, how about it?
