Sign in to follow this  
Followers 0
MCT

Adding Admin Password Via Script

7 posts in this topic

im trying 2 make a simple script that i can run to simply change the password of my administrator account

1 problem i cant seem 2 figure out

$passwd = InputBox("Please Choose Password", "Enter your password.", "", "")
RunWait(@ComSpec & " /k " & 'net user Administrator $passwd')

the password isnt set to whatever is in the input box , instead its set to $passwd

any help would be appreciated, im wanting 2 as u probly assume set the password via an input box

Share this post


Link to post
Share on other sites



im trying 2 make a simple script that i can run to simply change the password of my administrator account

1 problem i cant seem 2 figure out

$passwd = InputBox("Please Choose Password", "Enter your password.", "", "")
RunWait(@ComSpec & " /k " & 'net user Administrator $passwd')

the password isnt set to whatever is in the input box , instead its set to $passwd

any help would be appreciated, im wanting 2 as u probly assume set the password via an input box

<{POST_SNAPBACK}>

try

$passwd = InputBox("Please Choose Password", "Enter your password.", "", "")
RunWait(@ComSpec & " /k " & 'net user Administrator ' & $passwd)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thx man :lmao: it works i was trying for like 2 hrs lol

EDIT:

how can i make something like "if $passwd = blank" then do... else run the command

Edited by MCT

Share this post


Link to post
Share on other sites

Your problem. You entered the variable within the string. You should keep them seperate.

Share this post


Link to post
Share on other sites

right..

but how can i add this to my command

"if $passwd = blank (null)" then

msgbox(0, "Error", "Cannot Use Blank Passwords"

Elseif

RunWait(@ComSpec & " /k " & 'net user Administrator ' & $passwd)

Share this post


Link to post
Share on other sites

$passwd = InputBox("Please Choose Password", "Enter your password.", "", "*")
If $passwd = "" Then
;password is blank
Else
    RunWait(@ComSpec & " /k " & 'net user Administrator ' & $passwd)
EndIf

Share this post


Link to post
Share on other sites

ive been messing around with the new GUI stuff

ive got a button "Add User" & the username is typed in a text box, so how do i make it when u click the "add user" button it sets whatever's in the input box ($usrname is the variable i use)

#include <GUIConstants.au3>

GUICreate("User Account Creator") ; will create a dialog box that when displayed is centered

GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 300,200)

$tab0=GUICtrlCreateTabitem ("Add User")
GUICtrlSetState(-1,$GUI_SHOW)  ; will be display first
$tab0OK=GUICtrlCreateLabel ("Username", 20,50,80,50)
$usrname=GUICtrlCreateInput ("Administrator", 90,50,90,20)
$tab0OK=GUICtrlCreateLabel ("Password", 20,80,80,50)
$passwd=GUICtrlCreateInput ("MCT", 90,80,90,20)
$radio1 = GUICtrlCreateRadio ("Yes", 20, 150, 40, 20)
GUICtrlSetState ($radio1,$GUI_CHECKED)
$radio2 = GUICtrlCreateRadio ("No", 60, 150, 40, 20)
$tab0input=GUICtrlCreateLabel ("User is Admin", 20,130,80,20)
$tab0OK=GUICtrlCreateButton ("Add User", 170,150,80,20)

GUICtrlCreateTabitem ("")  ; end tabitem definition

GUISetState ()

Do
    $msg = GUIGetMsg()
    if $msg = $passwd then;i know this section isnt correct
    If $passwd = "" Then
RunWait(@ComSpec & " /k " & 'net user " & $usrname * /add"' )
RunWait(@ComSpec & " /k " & 'net accounts /maxpwage:unlimited' )
;password is blank
Else
RunWait(@ComSpec & " /k " & 'net user " & $usrname $passwd /add"')
RunWait(@ComSpec & " /k " & 'net accounts /maxpwage:unlimited' )
    endif

Until $msg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0