y0d4 0 Posted January 25 Share Posted January 25 Hi, I am working on script which should create user, set in administrator group, set password never expire etc. and to set password which is generated from hostname. Example: Quote $CMD = "Net user /add xyz 123" RunWait(@ComSpec & " /c " & $CMD) $CMD = "Net localgroup administrators xyz /add" RunWait(@ComSpec & " /c " & $CMD) $CMD = "WMIC USERACCOUNT WHERE Name='xyz' SET PasswordExpires=FALSE" RunWait(@ComSpec & " /c " & $CMD) $CMD = "WMIC USERACCOUNT WHERE Name='xyz' SET Passwordchangeable=FALSE" RunWait(@ComSpec & " /c " & $CMD) $CMD = "set hostname=%computername%" RunWait(@ComSpec & " /c " & $CMD) $CMD = "set newpassword=123.%hostname%.123" RunWait(@ComSpec & " /c " & $CMD) $CMD = "net user xyz password /add" RunWait(@ComSpec & " /c " & $CMD) $CMD = "net user xyz %newpassword%" RunWait(@ComSpec & " /c " & $CMD) This working great as batch, but as compiled exe do not want to set correct password, seems that code is not ok because of variables... Where i am wrong? thank you Link to post Share on other sites
ioa747 41 Posted January 25 Share Posted January 25 #RequireAdmin on top, no needed ? Link to post Share on other sites
y0d4 0 Posted January 25 Author Share Posted January 25 well, admin user will run that, so no for now... Link to post Share on other sites
Developers Jos 2,811 Posted January 25 Developers Share Posted January 25 The simple answer is that the environment values aren't persistent so they are lost after the command is completed! Just retink your approach here. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
y0d4 0 Posted January 25 Author Share Posted January 25 i was think on that and try to switch flag C to K but without luck Link to post Share on other sites
Developers Jos 2,811 Posted January 25 Developers Share Posted January 25 (edited) So why use a script here at all? You are simply emulating a batchfile run line by line? Edited January 25 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
y0d4 0 Posted January 25 Author Share Posted January 25 i want to hide how password looks from curios eyes I need to send this script to employee which have own PC and want to use for business purpose... so first i need admin user on that machine, so i can connect with new admin account. Link to post Share on other sites
Developers Solution Jos 2,811 Posted January 25 Developers Solution Share Posted January 25 So wouldn't this do the same thing ? : $CMD = "Net user /add xyz 123" RunWait(@ComSpec & " /c " & $CMD) $CMD = "Net localgroup administrators xyz /add" RunWait(@ComSpec & " /c " & $CMD) $CMD = "WMIC USERACCOUNT WHERE Name='xyz' SET PasswordExpires=FALSE" RunWait(@ComSpec & " /c " & $CMD) $CMD = "WMIC USERACCOUNT WHERE Name='xyz' SET Passwordchangeable=FALSE" RunWait(@ComSpec & " /c " & $CMD) $CMD = "net user xyz password /add" RunWait(@ComSpec & " /c " & $CMD) $CMD = "net user xyz 123." & @ComputerName & ".123" RunWait(@ComSpec & " /c " & $CMD) y0d4 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
y0d4 0 Posted January 25 Author Share Posted January 25 ah shame... did not saw/know that i can use @ComputerName All is fine, working flawless Thank you Jos, May the Force be with you! Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now