Administrator account from the command line in Windows 7. Also, prompt to change passord at login?

07
2014-07
  • guest

    How would I go about making an Administrator account from the command line in Windows 7. Also, prompt to change passord at login?

  • Answers
  • craig987

    Open Administrator command prompt.

    Enter this command to create the account. In this case joe is the login ID and PASSWORD is the password assigned to the account.

    net user joe PASSWORD /ADD /LOGONPASSWORDCHG:YES /FULLNAME:"Joe Smith"

    Enter this command to add the new account to the local administrators group.

    net localgroup administrators joe /ADD


  • Related Question

    On Windows 7, is there a command prompt line that can start cmd as an administrator?
  • 動靜能量

    This question already has an answer here:


  • Related Answers
  • Jared Harley

    The runas command is the closest thing to what you're looking for:

    runas /user:username cmd.exe
    

    The format is runas, the username you want to run as, other options, and then the program you want to run.

    If you're on a domain, you can use:

    runas /user:DOMAIN\Administrator cmd.exe
    

    This can be run from the Run box ( Win+R ) or from a command window.

    Note, however, that this is not exactly like sudo - you can't use it to elevate yourself, just run something as a different user. If you're already have administrative rights, a runas to your account will give you the same access as the regular command (unless, of course, you runas a different administrator account, which will grant those administrator's rights to the new shell).

  • Lance Roberts

    Try creating a shortcut to cmd.exe. Right Click > Properties. Click on Advanced button. And tick the box "Run as Administrator" and click OK.

    Assign it a shortcut key if you want.

    And you could also assign the default location for the CMD prompt to start in.. eg %CD%

  • Kippax

    Use SuRun It works in Windows 8 as well. It runs application in "admin" mode w/o prompt, yet you have greater control on what applications was run (you can see it's on the SuRun's control panel applet). Works great in the batch file too...

  • hanxue

    Another alternative is to click Start and type cmd, followed by Ctrl + Shift + Enter

    Source: Microsoft Technet

  • Tomáš Kafka

    You might like Sudo for Windows (but I haven't tried it yet)

  • afrazier

    The Open Command Prompt Shell Extension can add this capability for you as well.

  • Luke

    If you want a command line solution: download hstart from http://www.ntwind.com/software/hstart.html and extract hstart.exe or hstart64.exe to somewhere on your path, you can start an elevated command prompt with hstart /runas cmd or hstart64 /runas cmd

    But the fastest way (as noted in a comment for the question) is still to press Windows, type cmd and press ctrl+shift+enter.

  • Nicole Hamilton

    I include genuine su and sudo commands with my Hamilton C shell to run a command as another user or elevated (with the UAC prompt) or both, i.e., elevated as another user. Unlike runas and other alternatives, my su and sudo know how to pass current directories, environment variables and long command lines. This is a commercial product but there is a free version. Full disclosure: I'm the author. But I'm also happy to answer questions.

  • beyonddoor

    Create a batch file such as sudo.bat, and type the following commands and then save in the PATH:

    @echo Set objShell = CreateObject("Shell.Application") > %temp%\sudo.tmp.vbs
    @echo args = Right("%*", (Len("%*") - Len("%1"))) >> %temp%\sudo.tmp.vbs
    @echo objShell.ShellExecute "%1", args, "", "runas" >> %temp%\sudo.tmp.vbs
    @cscript %temp%\sudo.tmp.vbs
    

    To use it, for an instance, sudo cmd net start fms, however, the script won't work if there's quotemark in command line.

  • teh_senaus

    I was frustrated with the existing solutions for this, so I wrote a little Node.js script which should be more familiar to *nix users.

    It elevates the current user with no password prompts (just UAC), redirects stdin and stdout, and runs in the same console window.

    https://github.com/tehsenaus/windosu