school assignment, any help asap is very appreciated

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
wwilk80260
Posts: 1
Joined: 22 Feb 2012 19:23

school assignment, any help asap is very appreciated

#1 Post by wwilk80260 » 22 Feb 2012 19:40

Any help would be very much appreciated our instuctor has asked us to provide the following but never given any assitance nor taught the syntax or commands:
if this was python i understand the psuedo code should read something like "for x in line print hello
and so on ,

1)Write a batch file that iterates through a variable from 1 to 100 in steps of 5. For values of 1 – 50, the script should print “Hello”. For values between 51 and 100, the script should print “World.”

In as few lines as possible, write a batch file to create 20 users on your Win2k8 server using the net command

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: school assignment, any help asap is very appreciated

#2 Post by Squashman » 22 Feb 2012 20:04

Well I don't think posting twice will help you any quicker. What does your teacher get paid to do?

Open up a command prompt and type: for /?
You can do the same thing with the net command to see the syntax. Can probably do the same with Google.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: school assignment, any help asap is very appreciated

#3 Post by foxidrive » 22 Feb 2012 20:49

Here's some further help.

Use the FOR /L command to give you the numbers, range and the step size.

and use IF a variable is less than a number then do something
IF a variable is greater than a number then do something


You will need to research the commands to put that together so you'll at least learn something. :)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: school assignment, any help asap is very appreciated

#4 Post by foxidrive » 22 Feb 2012 21:10

wwilk80260 wrote:In as few lines as possible, write a batch file to create 20 users on your Win2k8 server using the net command


This is untested


Code: Select all

@echo off
for %%a in (a b c d e f g h i j k l m n o p q r s t) do net user "%%~a"

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: school assignment, any help asap is very appreciated

#5 Post by Squashman » 23 Feb 2012 06:22

foxidrive wrote:@echo off
for %%a in (a b c d e f g h i j k l m n o p q r s t) do net user "%%~a" /add

BallisticX
Posts: 3
Joined: 24 Feb 2012 21:04

Re: school assignment, any help asap is very appreciated

#6 Post by BallisticX » 24 Feb 2012 21:21

:roll: NUMBERS:
@echo off
title YOURNAME's ASSIGNMENT NAME

set t=0
:jhji
set /a t+=1
echo Number: %t%
if %t%==50 echo Hello
if %t%==100 echo World
@ping 127.0.0.1 -n 1 -w 1 >nulc
goto jhji



-BallisticX the 12 yr old programmer

BallisticX
Posts: 3
Joined: 24 Feb 2012 21:04

Re: school assignment, any help asap is very appreciated

#7 Post by BallisticX » 24 Feb 2012 21:27

typo its >nul
and dont echo Number: %t%
or u cant see echos

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: school assignment, any help asap is very appreciated

#8 Post by foxidrive » 24 Feb 2012 23:31

Read the requirements more closely, BallisticX

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: school assignment, any help asap is very appreciated

#9 Post by Squashman » 25 Feb 2012 08:14

BallisticX wrote::roll: NUMBERS:
@echo off
title YOURNAME's ASSIGNMENT NAME

set t=0
:jhji
set /a t+=1
echo Number: %t%
if %t%==50 echo Hello
if %t%==100 echo World
@ping 127.0.0.1 -n 1 -w 1 >nulc
goto jhji



-BallisticX the 12 yr old programmer

There is a reason we directed him to use a FOR loop. More efficient. Nor does your solution solve either of his problems.

Post Reply