Script to disable/enable a user

madmax2

New member
Member
Local time
2:21 PM
Messages
96
Hi,

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

enable/disable a user.

How can I do this?
 

My Computer

OS
Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
CPU
Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz
Motherboard
ASUSTeK Computer INC. P8Z68-V PRO
Memory
16.00 GB
Graphics Card(s)
AMD Radeon HD 6950
Sound Card
(1) AMD High Definition Audio Device (2) Webcam 250 (3)
Screen Resolution
1920 x 1080 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
(1) M4-CT064M4SSD2 ATA Device (2) M4-CT128M4SSD2 ATA Device (3) SAMSUNG HD103SJ ATA Device (4) WDC WD20EARX-00PASB0 ATA Device (5) WDC WD20EARX-00PASB0 ATA Device (6) WDC WD20 EARS-00MVWB0 SCSI Disk Device (7) Generic USB CF Reader USB De
PSU
Corsair HX 650
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

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
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

OS
Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
CPU
Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz
Motherboard
ASUSTeK Computer INC. P8Z68-V PRO
Memory
16.00 GB
Graphics Card(s)
AMD Radeon HD 6950
Sound Card
(1) AMD High Definition Audio Device (2) Webcam 250 (3)
Screen Resolution
1920 x 1080 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
(1) M4-CT064M4SSD2 ATA Device (2) M4-CT128M4SSD2 ATA Device (3) SAMSUNG HD103SJ ATA Device (4) WDC WD20EARX-00PASB0 ATA Device (5) WDC WD20EARX-00PASB0 ATA Device (6) WDC WD20 EARS-00MVWB0 SCSI Disk Device (7) Generic USB CF Reader USB De
PSU
Corsair HX 650
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

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
Back
Top