Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Built-in Administrator Account - Enable or Disable

01 Apr 2015   #270
Brink

64-bit Windows 10 Pro
 
 

See: http://www.sevenforums.com/3036855-post266.html


My System SpecsSystem Spec
02 Apr 2015   #271
fabfisc

Palermo
 
 

That's what your link says:

"If you like, you could use the same command in a .bat file. You would just need to right click on the .bat file and click on "Run as administrator"."


My System SpecsSystem Spec
02 Apr 2015   #272
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Quote   Quote: Originally Posted by fabfisc View Post
...[I] need a script (better if vbs) to do that as i manage many new notebooks to initialize (for first time) and then enable the admin account.
Hi Fabfisc,

The below batch script will enable the Administrator account if the account is disabled, and vice versa.
Code:
@net session >NUL 2>&1||powershell Start-Process '%0' -Verb RunAs>NUL&&exit /b|| exit /b
@net user Administrator|find "active"|find "Yes">NUL&&( net user Administrator /active:no&&echo The Administrator account is now Disabled. )||( net user Administrator /active:yes&&echo The Administrator account is now Enabled. )
@timeout 2 >NUL & rem tsdiscon
And a VBScript translate of the above,
Code:
Set objShell = CreateObject("WScript.Shell")
If Not objShell.Run("Net Session",0,True) = 0 Then
	CreateObject("Shell.Application").ShellExecute "WScript.exe", WScript.ScriptFullName,"","RunAs",1
	WScript.Quit
End If

If objShell.Run("cmd /c ""Net User Administrator|Find ""active""|Find ""Yes""""", 0, True) = 0 Then
	objShell.Run "Net User Administrator /Active:No", 0, True
	objShell.Popup "The Administrator account is now Disabled.", 1.5, "Success", 64
Else
	objShell.Run "Net User Administrator /Active:Yes", 0, True
	objShell.Popup "The Administrator account is now Enabled.", 1.5, "Success", 64
End If

rem WScript.Sleep 2000 : objShell.Run "tsdiscon", 0, True
My System SpecsSystem Spec
02 Apr 2015   #273
fabfisc

Palermo
 
 

It seems that when i run both scripts, i receive the same result:

"The Administrator account is now Enabled."

All that even if i see (by typing "net use administrator") the referred value of variable "Enable account" set to "Yes"

It seems that the second time i run the script it doesn't see the value "Yes"...
My System SpecsSystem Spec
.

02 Apr 2015   #274
fabfisc

Palermo
 
 

Half solved!

Here is the correct script for the vbs part:

Quote:
Dim WshShell : set WshShell = Wscript.CreateObject("WScript.Shell")

If WshShell.Run("cmd /c ""Net User Administrator|Find ""attivo""|Find ""Sì""""", 0, True) = 0 Then
WshShell.Run "Net User Administrator /active:No", 0, True
WshShell.Popup "The Administrator account is now Disabled.", 1.5, "Success", 64
Else
WshShell.Run "Net User Administrator /active:Yes", 0, True
WshShell.Popup "The Administrator account is now Enabled.", 1.5, "Success", 64
End If
Trying to find the right way to do the same via .cmd (for now, it always returns "The Administrator account is now Enabled."
My System SpecsSystem Spec
02 Apr 2015   #275
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Ah. Silly me. I didn't take your country flag into account, Fabfisc.

So here is what the Italian verson for the batch (.bat|.cmd) version of the enable/disable Administrator script would look like.
Code:
@net session >NUL 2>&1||powershell Start-Process '%0' -Verb RunAs>NUL&&exit /b|| exit /b
@net user Administrator|find "attivo"|find "Si">NUL&&( net user Administrator /active:no&&echo The Administrator account is now Disabled. )||( net user Administrator /active:yes&&echo The Administrator account is now Enabled. )
@timeout 2 >NUL & rem tsdiscon

By the way, in your VBScript, Fabfisc, you seem to have assigned to a variable retcode but you never use it. Please do something about it, it's making me cringe .
My System SpecsSystem Spec
03 Apr 2015   #276
fabfisc

Palermo
 
 

Yep, i though i removed that line, it was only for test.

I edited and correct it.

Many thanks
My System SpecsSystem Spec
22 May 2015   #277
thuanphat2015

Windows 7 Ultimate x64
 
 

Option 1 work Good. No Error
My System SpecsSystem Spec
Comment

 Built-in Administrator Account - Enable or Disable




Tutorial Tools




Similar help and support threads
Windows 7 Tutorial Category
how do I enable hidden administrator (not built-in) account on log-on?
Hi Geeks, I tried to hide a standard user account from appearing on log-on screen through registry editor, with help obtained from internet. But i accidentally left a new key (without renaming) in SpecialAccount>UserList. When I switched user, only the standard user account is shown. The...
General Discussion
Built-in Administrator - Enable from WinRE
How to Enable the Built-in Elevated "Administrator" Account from WinRE Theoretically if you don't have any administrator account, the built-in Administrator account should be available in safe mode (see also related articles). Sometimes due to any identified reason, the built-in Administrator...
Tutorials
Built in administrator account at log in
I have a Sony vaio laptop running windows 7. Recently I restored it to a previous state, so I decided to create a password for my admin account. Once I completed the password set up I restarted my computer to see if my password will work. Well it didn't. I Got message "your account has been...
General Discussion
Windows XP Mode - Enable Built-in Administrator Account
How to Enable the Built-in Administrator Account in Windows XP Mode When you install and launch Windows XP Mode for the first time it has following account related defaults: Default user: XPMUser Integration Features enabled Built-In Administrator account disabled All user accounts must...
Tutorials
How do I repair the built-in Administrator account ?
I accidentally deleted the profile list for the administrator account. I enabled the administrator account by opening command prompt as an Administrator and typed in net user administrator /active:yes . When I logged into the Administrator account I was told I am logged in as a temporary account....
General Discussion
Built-In Administrator Account
I have a couple of questions regarding the Built-In Administrator Account First some info. 1. I purchased my computer in January 2011 2. I am the sole user of the computer 3. I have set up two accounts with Administrator privileges. Each one has its own unique name and unique password. 4....
Installation & Setup


Our Sites

Site Links

About Us

Find 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 17:31.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App