Jump to content

Variables wrong (4 and 5??) cmd user account


Recommended Posts

Hi!,

I am trying to create a tool that will create a custom user account, based on a given user name and password. I user a gui creation tool for the 1st bit.

If you are not familiar with cmd or "net user", it is a tool for creating a user account from the terminal, even for non-admins!.

So my code has two inputs then it runs cmd and sends "net user $input1 $input2 /add" it all works up until the net input variables, where they always equal 4 and 5.

How and why do they always equal 4/5 no matter what i type??

GuiCreate("User Account Creator",259,284,364,271)

$button1=GuiCtrlCreateButton("Start",118,235,27,11)

$input1=GuiCtrlCreateInput("USERNAME HERE",37,143,27,20)

$input2=GuiCtrlCreateInput("Password HERE",79,172,27,20)

$label1=GuiCtrlCreateLabel("New User Account creator",113,75,60,15)

GuiSetState()

While 1

$msg=GuiGetMsg()

If $msg=-3 Then Exit

If $msg=$button1 Then button1()

Wend

Func button1()

Run("CMD")

sleep(50)

send("@echo off")

sleep(50)

send("{ENTER}")

sleep(50)

send("cls")

send("{enter}")

sleep(50)

send("net user")

sleep(150)

send("{space}")

Send($input1) ----- It starts going wrong here, by sending 4

sleep(10)

send("{space}")

Send($input2) ---- it sends 5 here

sleep(150)

send("{space}")

send("/add")

sleep(150)

send("{enter}")

EndFunc

Link to comment
Share on other sites

I don't think anyone on this forum needs instruction on the uses of NET.exe. :mellow:

Those are the ControlIDs of the Input controls you created, not the data from them. Read them with GuiCtrlRead(). Read your help file while your're at it.

You are in for nothing but pain if you try to keep sending commands to the CMD console. Just assemble a single command line and Run() that:

RunWait(@ComSpec & " /c NET USER " & $sUserName & " " & $sPassword & " /ADD")

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

So how do I define the data, from the inputs. :lo

Beacuse I start AutoIT yesterday (04/5/2010 for the viewers on DAVE :mellow: ) I have no idea what that text means :(

So unless i won't be able to define the data, using the long way, how do i do it??

I am guessing:

Send("GuiCtrlRead($input1)")

or is that a complete fail :lol:

Link to comment
Share on other sites

Why are you guessing?

If you take the quotation marks off that it might work. But if you will not learn to run commands without Send()'ing them to a CMD console, you won't get very far with AutoIt.

Do the short tutorials in the help file, then run the example scripts list under each of the relevant functions, like GuiCtrlCreateInput() and GuiCtrlRead(). When you're ready for more, try the AutoIt 1-2-3 tutorial in my sig.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi,

I tried some of the tutorials and i put together a command like your one:

RunWait(@ComSpec & " /c " & "net user "$input1" "$input2" /add")

but it says there is an error in the expression.??

what does this mean??

You forgot some "&" operators when assembling your string:
RunWait(@ComSpec & " /c " & "net user " & $input1 & " " & $input2 & " /add")

:mellow:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...