Jump to content
Sign in to follow this  
dspent

Adding Domain Users to a Local Group

Recommended Posts

dspent

There is a local group on every machine called REMOTE CONTROL OPERATORS,

what i need to do is add about 12 domain users to this group on each NT/XP/2000 machine.

The command line way to do this is:

NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"

How do I use AutoIt to do this for every machine on the network.

Share this post


Link to post
Share on other sites
Doxie

Please first read the help file, and try to come up with a script, and if you can't get it working, i will gladly help you.


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Doxie

Ok, i help you, since my dinner is in the owen :idiot:

From the FAQ

5. How can I run a DOS program from within AutoIt?

If you wanted to run something like a DOS "Dir" command then you must run it though the command interpreter (command.com or cmd.exe depending on your OS). The @Comspec macro contains the correct location of this file. You should use the RunWait() function as it waits for the DOS program to finish before continuing with the next line of the script. Here is an example of running the DOS Dir command on the C: drive: (effectively running the command command.com /c Dir C:\ )

RunWait(@COMSPEC & " /c Dir C:\")

Wich means your could would look something like this:

RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
Sleep (3000)
RunWait(@COMSPEC & " /c NET LOCALGROUP NAME OF LOCAL GROUP /ADD "USERNAME TO ADD"")
MsgBox(4096, "Done", "You are now done", 10)

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
dspent

and how do I run that on every machine on the network...?

Share this post


Link to post
Share on other sites
ioliver

and how do I run that on every machine on the network...?

<{POST_SNAPBACK}>

Do you have a Server? If so, you can make it part of the logon script...

Or

Search for a program called PSEXEC...

Hope that helps,

Ian

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites
Doxie

You put the script above on a share everyone can acccess.

Then you add some lines in your login script.

This is a copy of my login script, of course you can't use the exact same.

:NEWPATCH
REM ********************************************************************
REM ** Installs new patch                                             **
REM ********************************************************************
    IF EXIST \\xp2app02\Win2000\tools\PatchTool\USERS\%COMPUTERNAME%.DONE GOTO NEWPATC2
"\\xp2app02\Win2000\tools\PatchTool\patchtool.exe"
    GOTO SCREEN

As you can see it first check for a file that is created by my script, in this case patchtool.exe. If the file exist then goto next thing in the login script. If not, then run the patchtool.

So in you code above you could add a line, where it create a file for each user that have run the script. You can look after Iniwrite in the help file. All this would help, so it does not try to run it several times.


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Domonoky

Hi..

i think the easiest thing is the use of psexec, a tool from sysinternal (freeware). With this tool you could remotly execute your script on the PC´s.

And i think it should be simplier, using a batch file instead of an autoit script..

mfg Domo

Edited by Domonoky

Share this post


Link to post
Share on other sites
Doxie

Of course it would be simplier to use batch file...

But would it be as much fun as with AutoIt, i doubt that :idiot:


Were ever i lay my script is my home...

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  

×