troubleshooting Question

Need help with a XP Shell script to create local groups based on a file

Avatar of washy16
washy16Flag for Canada asked on
Windows BatchWindows XP
24 Comments1 Solution556 ViewsLast Modified:
Hi Experts! I've never done scripting in the Windows Shell before and I need some help.

Based on a .txt file I need to make a script that creates local groups but only creates a group if it doesn't already exist. I can create groups without a hitch, but I'm stuck on how to only make it if it doesn't exist part. The sample txt file I'm working with looks like this:

**************************************************************
New Employees
**************************************************************

LastName       FirstName      employeeID      Department
--------------------------------------------------------------
Doe                       John               A003            News
Smith             Dave                 B005            Distribution

The code I have to create the group so far is this:

FOR /f "tokens=4 skip=6" %%a IN (HiredPersonnelTest.txt) DO NET LOCALGROUP %%a /add



Any help would be appreciated.

Thanks.
Washy
ASKER CERTIFIED SOLUTION
t0t0

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 24 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 24 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros