Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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