Sign in to follow this  
Followers 0
Agent Orange

Error -1

13 posts in this topic

I'm getting this an error line -1 running the below code. Any one tell me what is wrong with the expression?

Thanks

$Username=InputBox("Client Username","Please type the client username so it can be entered into the Power Users Group.","")
$RET = RunWait(@ComSpec & " /c " & "net localgroup power users mydomain\"$username" /add",@WorkingDir, @SW_SHOW)
MsgBox(64, "Result", "Return code was: " & $RET)

Share this post


Link to post
Share on other sites



From the helpfile.

Runwait.

Return Value

Success: Returns the exit code of the program that was run.

Failure: Depends on RunErrorsFatal; see Remarks.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You aren't getting -1 as returncode with the posted code since it contains syntax errors, unless you compile it first and then run it.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Nvm, my bad. I didn't looked close enough.

RunWait(@ComSpec & " /c " & "net localgroup power users mydomain\" & $username & " /add",@WorkingDir, @SW_SHOW)

Share this post


Link to post
Share on other sites

Nvm, my bad. I didn't looked close enough.

RunWait(@ComSpec & " /c " & "net localgroup power users mydomain\" & $username & " /add",@WorkingDir, @SW_SHOW)

Thanks for the response. Still didn't work, I got a return code 2 this time.

Share this post


Link to post
Share on other sites

Thanks for the response. Still didn't work, I got a return code 2 this time.

Did you try the command from the CMD prompt first to see if its valid?

Pretty sure you will get an error :)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Did you try the command from the CMD prompt first to see if its valid?

Pretty sure you will get an error :)

I did try it and the command works fine from a command prompt on the workstation. It successfully completes and when I go into the Power Users Group I see the user in there. I can delete the user from the group and run from a command line and it will readd it. If I try to run it from the AutoIt script I get the error 2 and no user is added to the group.

Thanks

Share this post


Link to post
Share on other sites

I did try it and the command works fine from a command prompt on the workstation. It successfully completes and when I go into the Power Users Group I see the user in there. I can delete the user from the group and run from a command line and it will readd it. If I try to run it from the AutoIt script I get the error 2 and no user is added to the group.

Thanks

It works for you without putting the groupname Power Users in double quotes?

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

It works for you without putting the groupname Power Users in double quotes?

The command I'm running on the workstation is net localgroup "power users" domain\user /add

I'm not sure the syntaxt for this when put into the autoit code line. The options I've tried cause an error

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

The command I'm running on the workstation is net localgroup "power users" domain\user /add

I'm not sure the syntaxt for this when put into the autoit code line. The options I've tried cause an error

That is what I ment, you cannot just leave the double quotes, else the command line is not the same.

Should be something like:

RunWait(@ComSpec & ' /c net localgroup "power users" mydomain\' & $username & ' /add',@WorkingDir, @SW_SHOW)
Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Edit: Too slow :)

Edited by walle

Share this post


Link to post
Share on other sites

and ... better check it too :)

That worked Jos....Thanks

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  
Followers 0