Jump to content

Error -1


Recommended Posts

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)
Link to comment
Share on other sites

  • Developers

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

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

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 :)

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

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

Link to comment
Share on other sites

  • Developers

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?

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

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

Link to comment
Share on other sites

  • Developers

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

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