Jump to content

System variables


y0d4
 Share

Go to solution Solved by Jos,

Recommended Posts

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

  • Developers

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

  • Developers

So why use a script here at all? You are simply emulating a batchfile run line by line?

Edited 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

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

  • Developers
  • Solution

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)

 

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...