Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

I need help with a MS-DOS batch file


  • Please log in to reply

#1
x3Chamberx3

x3Chamberx3

    New Member

  • Member
  • Pip
  • 1 posts
I've been trying to get this script to work for about 2 hours and am not sure where i'm going wrong. I'm new to writing batch files, especially in MS-DOS but here's what I have so far.

for /f %%1 in ("users.txt") do net user /add %%1


Its "supposed" to look in users.txt and read the names of the users and create accounts for them. Inside the file i created user1 user2 user3 etc.

Is there anyone who could fill me in on what i'm missing or what i set up wrong ? thanks
  • 0

Advertisements


#2
gust0208

gust0208

    Member

  • Member
  • PipPipPip
  • 311 posts
Hello,

I was able to get this working and I will put down the bat code and the "users.txt" code. Basically, I just removed the quotes from around the (users.txt) and used my usual naming convention for the for loop.

create_netusers.bat:
@echo off
FOR /f %%c in (users.txt) DO net user /add %%c
REM You may have to adjust the net user call, but this will parse the users.txt file
:END

users.txt:
user1
user2
user3

Cheers!
Tom

I've been trying to get this script to work for about 2 hours and am not sure where i'm going wrong. I'm new to writing batch files, especially in MS-DOS but here's what I have so far.

for /f %%1 in ("users.txt") do net user /add %%1
Its "supposed" to look in users.txt and read the names of the users and create accounts for them. Inside the file i created user1 user2 user3 etc.

Is there anyone who could fill me in on what i'm missing or what i set up wrong ? thanks


  • 0

#3
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP

for /f %%1 in ("users.txt") do net user /add %%1

Your problem was that you put the filename in quotation marks. That will fail.... (because Windows batch scripting syntax is silly.)

This would work:

for /f %%1 in (users.txt) do net user /add %%1

:tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP