• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Create OS user in java

 
Ranch Hand
Posts: 152
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Straws are for suckers. Now suck on this tiny ad!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic