Read IP then run .bat ???

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alexf5
Posts: 4
Joined: 06 Oct 2016 20:42

Read IP then run .bat ???

#1 Post by alexf5 » 06 Oct 2016 20:58

I have a file a1.bat with this code:

Code: Select all

CLIREG32.EXE abc.VBR -s 10.1.0.aa -d -nologo -t abc.TLB -u
CLIREG32.EXE abc.VBR -s 10.1.0.aa -d -nologo -t abc.TLB
:ENDREG
+...............................



I wanna create a bat file that

Code: Select all

  Type to input AA value 
    if aa=xx then run a1.bat
    unless run a1.bat with yy value
    unless run a1.bat with zz value

Tks for your support, i'm waiting,

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

Re: Read IP then run .bat ???

#2 Post by foxidrive » 07 Oct 2016 03:18


ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Read IP then run .bat ???

#3 Post by ShadowThief » 07 Oct 2016 05:50

alexf5 wrote:Tks for your support, i'm waiting,

Image

alexf5
Posts: 4
Joined: 06 Oct 2016 20:42

Re: Read IP then run .bat ???

#4 Post by alexf5 » 10 Oct 2016 20:00

final, i need the code of that .bat here, i don't want to read other posts,

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Read IP then run .bat ???

#5 Post by ShadowThief » 10 Oct 2016 21:33

Well, thankfully the mods are asleep so I can (try to) answer your question before it gets locked for you having a terrible attitude.

My answer depends on the flow of your script being like this:
  • Ask the user to type xx, yy, or zz
  • If your input is the literal string xx, pass some value to a1.bat
  • If your input is the literal string yy, pass some other value to a1.bat
  • If your input is the literal string zz, pass some third value to a1.bat
  • Do not accept any other inputs from the user
  • Replace the aa in a1.bat with the final octet as provided by user input (by the way, this is going to require a rewrite of the code you've shown us, because what you've posted will never ever work in a million years; aa is treated like a string instead of a variable so clireg.exe will always receive the input 10.1.0.aa no matter what).

That said, I have no idea what
unless run a1.bat with yy value
unless run a1.bat with zz value

is supposed to mean, so I'm just guessing.

Code: Select all

@echo off

:getInput
set /p "aa=Enter AA value: "

if /i "%aa%"=="xx" (
   echo call a1.bat 1
) else if /i "%aa%"=="yy" (
   echo call a1.bat 2
) else if /i "%aa%"=="zz" (
   echo call a1.bat 3
) else (
   echo Invalid input. Please enter xx, yy, or zz.
   goto getInput
)
exit /b


To get this to work, you're going to have to change the code of a1.bat to

Code: Select all

CLIREG32.EXE abc.VBR -s 10.1.0.%1 -d -nologo -t abc.TLB -u
CLIREG32.EXE abc.VBR -s 10.1.0.%1 -d -nologo -t abc.TLB
:ENDREG


Although if you're going to edit the code of a1.bat anyway, you might as well just put the input code at the top of the script so that you don't have to write a batch wrapper for a batch script, which is just a ridiculous notion IMO.

alexf5
Posts: 4
Joined: 06 Oct 2016 20:42

Re: Read IP then run .bat ???

#6 Post by alexf5 » 11 Oct 2016 20:20

Tks, solved !

Post Reply