Link to home
Start Free TrialLog in
Avatar of andykatafiaszwestfield
andykatafiaszwestfieldFlag for United States of America

asked on

DOS Batch file command - inserting data

I need to have a batch file run that will add a user to a specific local group. I know the cvommand line is

net localgroup "Groupname" "username" \add.

However, I need  to allow the user to add him or herself into the "username" area when the batch file runs.

This should be in a DOS command manner, or a script that can be called up when the batch file runs.

Any ideas out there?

Thanks in advance.
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Three options:
1.  Have the user specify the user name on the command line - MYBATCH USERNAME
Then in the batch file, in place of username, use %1

2.  Have the batch file prompt the user for the username -
SET /P Useraccount=Please Enter your username:
Then reference %Useraccount%

3.  Use the username automatically.
net localgroup "Groupname" "%username%"
SOLUTION
Avatar of swesluggo
swesluggo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you should be able to use the %USERNAME% variable in your batch file.
net localgroup "groupname" %username% /add
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial