Page 1 of 1

school assignment, any help asap is very appreciated

Posted: 22 Feb 2012 19:40
by wwilk80260
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

Re: school assignment, any help asap is very appreciated

Posted: 22 Feb 2012 20:04
by Squashman
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.

Re: school assignment, any help asap is very appreciated

Posted: 22 Feb 2012 20:49
by foxidrive
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. :)

Re: school assignment, any help asap is very appreciated

Posted: 22 Feb 2012 21:10
by foxidrive
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"

Re: school assignment, any help asap is very appreciated

Posted: 23 Feb 2012 06:22
by Squashman
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

Re: school assignment, any help asap is very appreciated

Posted: 24 Feb 2012 21:21
by BallisticX
: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

Re: school assignment, any help asap is very appreciated

Posted: 24 Feb 2012 21:27
by BallisticX
typo its >nul
and dont echo Number: %t%
or u cant see echos

Re: school assignment, any help asap is very appreciated

Posted: 24 Feb 2012 23:31
by foxidrive
Read the requirements more closely, BallisticX

Re: school assignment, any help asap is very appreciated

Posted: 25 Feb 2012 08:14
by Squashman
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.