• Post Reply Bookmark Topic Watch Topic
  • New Topic

Create OS user in java  RSS feed

 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I want to create an OS user in windows using Java 5/6. Can anyone guide me in how to implement this functionality.

Thanks in advance.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pravin Shirke wrote:Hi Ranchers,

I want to create an OS user in windows using Java 5/6. Can anyone guide me in how to implement this functionality.

Thanks in advance.

In pure Java you cannot do that ...but still if you want to do this
try written .bat file which will create user in windows or .sh for Linux and then execute that file from Java using Runtime.exec(...); or ProcessBuilder
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Windows, the command to create a user is net user (issue net help user on the command prompt to get help). Of course, you need to have some privileges to be able to create a user, and it will be a local user (if you run the command on a domain server, perhaps you can create a domain user - I'm not sure about this).

It is possible to create a BAT file a and run that, as Naved suggests, but you can execute the net user command directly as well, the BAT file is not strictly required.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote: the BAT file is not strictly required.

Yes, that's true, but suppose you want to modify the command then creating .bat or .sh is more handy so that you don't have to recompile your source code again & again for each modification.I hope its clear
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!