Command Line question

  • Thread starter Thread starter Robert Harris
  • Start date Start date
R

Robert Harris

Is it possible to take the answer of a question asked from a command line
and assign it to a variable using just Command Line scripting or does this
involve using VBScript only?
 
Is it possible to take the answer of a question asked from a command line
and assign it to a variable using just Command Line scripting or does this
involve using VBScript only?

Try 'SET /P var=prompt'; see 'SET /?'.
 
One more question. I am having a hard time with this that I have wrote:

1. @echo off

2. REM Specify object Type and how many objects are to be added
3. Set /P domainName=What is the name of the Domain (.com will be appended)?
4. Set /p ouName=What is the name of the container?
5. Set /p objectType=Specify the object Type (Enter Computer or user):
6. Set /p howMany=How many %objectType%s?

7. REM --------------------------------------------------
8. Rem Iterate through the value set by howMany variable and assign object
name to variables
9. For /l %%B in (1,1,%howMany%) do (Set /p addObject%%B=Enter entry ^#
%%B:)

10. REM assign object variables to CVS string
11.For /l %%B in (1,1,%howMany%) do echo
"CN=addObject%%B,OU=%ouName%,DC=%domainName%,DC=com" >> C:\%objectType%.txt

My problem is on line 11. On line 9 I have assigned the names to variables
in the for loop. Now I want to plug those names in on line 11 where
CN=addObject but I can't figure out how to access them. I know the syntax I
have there now is wrong, I just left it that way.
 
One more question. I am having a hard time with this that I have wrote:

1. @echo off

2. REM Specify object Type and how many objects are to be added
3. Set /P domainName=What is the name of the Domain (.com will be appended)?
4. Set /p ouName=What is the name of the container?
5. Set /p objectType=Specify the object Type (Enter Computer or user):
6. Set /p howMany=How many %objectType%s?

7. REM --------------------------------------------------
8. Rem Iterate through the value set by howMany variable and assign object
name to variables
9. For /l %%B in (1,1,%howMany%) do (Set /p addObject%%B=Enter entry ^#
%%B:)

10. REM assign object variables to CVS string
11.For /l %%B in (1,1,%howMany%) do echo
"CN=addObject%%B,OU=%ouName%,DC=%domainName%,DC=com" >> C:\%objectType%.txt

My problem is on line 11. On line 9 I have assigned the names to variables
in the for loop. Now I want to plug those names in on line 11 where
CN=addObject but I can't figure out how to access them. I know the syntax I
have there now is wrong, I just left it that way.
[snip]

Research CMD's "Delayed Variable Expansion" (/V:ON and "!"); see CMD /?.

Or move the operation to a subroutine - these three links might get you
started (they are the 2nd-4th results when googling for "xp delayed
variable expansion"
<http://groups.google.com/groups?as_q=xp delayed variable expansion>):

<http://groups.google.com/[email protected]>
<http://groups.google.com/[email protected]>
<http://groups.google.com/[email protected]>
 
Back
Top