y0d4 Posted January 25, 2023 Share Posted January 25, 2023 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 comment Share on other sites More sharing options...
ioa747 Posted January 25, 2023 Share Posted January 25, 2023 #RequireAdmin on top, no needed ? I know that I know nothing Link to comment Share on other sites More sharing options...
y0d4 Posted January 25, 2023 Author Share Posted January 25, 2023 well, admin user will run that, so no for now... Link to comment Share on other sites More sharing options...
Developers Jos Posted January 25, 2023 Developers Share Posted January 25, 2023 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 comment Share on other sites More sharing options...
y0d4 Posted January 25, 2023 Author Share Posted January 25, 2023 i was think on that and try to switch flag C to K but without luck Link to comment Share on other sites More sharing options...
Developers Jos Posted January 25, 2023 Developers Share Posted January 25, 2023 (edited) So why use a script here at all? You are simply emulating a batchfile run line by line? Edited January 25, 2023 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 comment Share on other sites More sharing options...
y0d4 Posted January 25, 2023 Author Share Posted January 25, 2023 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 comment Share on other sites More sharing options...
Developers Solution Jos Posted January 25, 2023 Developers Solution Share Posted January 25, 2023 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 comment Share on other sites More sharing options...
y0d4 Posted January 25, 2023 Author Share Posted January 25, 2023 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 comment Share on other sites More sharing options...
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