2

Is it possible to create/delete windows user account and set its privileges to make it admin account , simple user account or guest account using java code ?

2
  • When you have administrative privileges, I think it is possible to do that. However, I don't know how. Commented Mar 29, 2014 at 19:35
  • for the admin privileges it is possible when you include a .manifest file to have these privilegs but i think i will choose the the naive way by executing a simple command line . Commented Mar 30, 2014 at 16:22

1 Answer 1

6

It's been already 1 year when i asked this question and i forgot to post the answer. I'm sorry :)

to create a user account we need administrative privileges by wrapping a manifest file with our program. the manifest file must have the same name as the program. this how this file should look like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable"   uiAccess="False" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>  

then we create our userAccount program :

import java.io.IOException;

public class UserAccount {

    public static void main(String[] args){

        String userName = "foo";

        try {

            Runtime.getRuntime().exec("net user " + userName + " /add");

        } catch (IOException e){
            e.printStackTrace();
        }
    }
}

in my case i used the launch4j tool to wrap the manifest with the .jar file and get the program working :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.