Jump to content
Sign in to follow this  
platypoos

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

Recommended Posts

platypoos

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
platypoos

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:

Share this post


Link to post
Share on other sites
platypoos

I just figured it out!!

Send(GuiCTRLRead( 4))

But how do you know what the controlIDs are going 2 be ??

And also what does that text PsaltyDS put earlier mean ??

I know I am not very good at this...

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
platypoos

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??

Share this post


Link to post
Share on other sites
PsaltyDS

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.