Script to disable/enable a user


  1. Posts : 96
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
       #1

    Script to disable/enable a user


    Hi,

    I need a script/batch file that I can click to quickly

    enable/disable a user.

    How can I do this?
      My Computer


  2. Posts : 2,465
    Windows 7 Ultimate x64
       #2

    A one-liner bat file can do that pretty easy. This will do the trick:

    To enable a user:
    Code:
    net user username /active:yes
    To disable it:
    Code:
    net user username /active:no
    Where username is the username to enable/disable.
    This requires administrator permission to succeed.

    Some reference can be found here:
    Enable or Disable user account from command line (CMD)
      My Computer


  3. Posts : 96
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
    Thread Starter
       #3

    Alejandro85 said:
    A one-liner bat file can do that pretty easy. This will do the trick:

    To enable a user:
    Code:
    net user username /active:yes
    To disable it:
    Code:
    net user username /active:no
    Where username is the username to enable/disable.
    This requires administrator permission to succeed.

    Some reference can be found here:
    Enable or Disable user account from command line (CMD)
    yeah i saw that command when i did a google search previously.

    It works but only when I run the command inside a command prompt
    or calling the batch file in the command prompt.

    It doesn't work when I doubt click the batch file.

    Can u upload a batch file that allows me to doubt click and run it in explorer?
      My Computer


  4. Posts : 2,465
    Windows 7 Ultimate x64
       #4

    That line is the whole bat file required to do it, there isn't anything more to it. It works the very same way in the command prompt or in a bat file or in any other way you invoke it.

    Remember you must be administrator for it to succeed. Otherwise you'll be greeted by an access denied error. Of course you must run the bat file as administrator, in the very same way you likely did at the command prompt.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:13.
Find Us