Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 779
  • Last Modified:

Creating an interactive script

I have 3 scripts that need to be run during a multiple server deployment.  I'm telling the engineer to go into each script and change a couple variables in the scripts and then run them.  But they'd rather have one script run that parses through the 3 scripts and changes the information for them, meaning this 4th script would prompt them to change the variables, the 3 scripts would change.  And then the engineer would change the 3 scripts.  The engineer would not have to go into each script and do a lot of typing.  They could then run the 3 scripts.  The scripts are below.  I underlined what would need to be changed in each script.  Does anyone have any ideas?

fileshare.bat
icacls d:\apps /grant isbnj\brXXXusers:(OI)(CI)M
icacls d:\home /grant isbnj\brXXXusers:(OI)(CI)M

dhcpscope.bat
netsh dhcp server add scope 10.20.30.0 255.255.255.0 "Data Scope"
netsh dhcp server scope 10.20.30.0 set state 1
netsh dhcp server scope 10.20.30.0 add iprange 10.20.30.1 10.20.30.200
netsh dhcp server scope 10.20.30.0 set optionvalue 003 IPADDRESS 10.20.30.254
netsh dhcp server scope 10.20.30.0 set optionvalue 242 IPADDRESS VLAN2

netsh dhcp server add scope 40.50.60.0 255.255.255.0 "Voice Scope"
netsh dhcp server scope 40.50.60.0 set state 1
netsh dhcp server scope 40.50.60.0 add iprange 40.50.60.1 40.50.60.200
netsh dhcp server scope 40.50.60.0 set optionvalue 003 IPADDRESS 40.50.60.254
netsh dhcp server scope 40.50.60.0 set optionvalue 242 IPADDRESS VLAN10,HTTPSRVR=x.x.x.x

printerports.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1]
"Protocol"=dword:00000001
"Version"=dword:00000002
"HostName"="MICR1_IP"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"=""
"SNMP Enabled"=dword:00000000
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\TLR1]
"Protocol"=dword:00000001
"Version"=dword:00000002
"HostName"="TLR1_IP"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"=""
"SNMP Enabled"=dword:00000000
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\PLT1]
"Protocol"=dword:00000001
"Version"=dword:00000002
"HostName"="PLT1_IP"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"=""
"SNMP Enabled"=dword:00000000
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\PLT2]
"Protocol"=dword:00000001
"Version"=dword:00000002
"HostName"="PLT2_IP"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"=""
"SNMP Enabled"=dword:00000000
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\PLT3]
"Protocol"=dword:00000001
"Version"=dword:00000002
"HostName"="PLT3_IP"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"=""
"SNMP Enabled"=dword:00000000
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\PLT4]
"Protocol"=dword:00000001
"Version"=dword:00000002
"HostName"="PLT4_IP"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"=""
"SNMP Enabled"=dword:00000000
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\PLT5]
"Protocol"=dword:00000001
"Version"=dword:00000002
"HostName"="PLT5_IP"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"=""
"SNMP Enabled"=dword:00000000
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000



0
sedberg1
Asked:
sedberg1
1 Solution
 
Gary DewrellSenior Network AdministratorCommented:
First let me say I am NOT an expert in scripting. : )
I have done something simular to what you are looking for though.

I have one script that is ran that the user passes argumetns to on the command line.

myscript. arg1 arg2 arg3 arg4 etc.....
That script calls other scripts and and passes the appropriate arguments on thier command line.
myscript2 arg2 arg3 etc..

As for the REG files you may have to write new reg files via script then execute the reg files.

Script3
echo " [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\PLT5]" >> reg1
echo "bla bla bla" >> reg1
echo "HostName=" arg1 >> reg1


Not where I can pull up my scrpt at the moment but if this does not get you pointed in the correct direction I can post some sample code later.
0
 
sedberg1Author Commented:
Found it.  Basically converted everything to one batch file and used " set /P" to create variables in the script.

Example:
REM These lines prompt the user to put in the IP addresses of the branch printers
SET /P MICR1_IP="Enter MICR1 TCP/IP Address: "
SET /P TLR1_IP="Enter TLR1 TCP/IP Address: "
SET /P PLT1_IP="Enter PLT1 TCP/IP Address: "
SET /P PLT2_IP="Enter PLT2 TCP/IP Address: "
SET /P PLT3_IP="Enter PLT3 TCP/IP Address: "
SET /P PLT4_IP="Enter PLT4 TCP/IP Address: "
SET /P PLT5_IP="Enter PLT5 TCP/IP Address: "

REM This enters the IP address of the MICR1 printer
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1"
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v Protocol /t REG_DWORD /d 00000001
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v version /t REG_DWORD /d 00000002
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v HostName /t REG_SZ /d %MICR1_IP%
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v IPAddress /t REG_SZ /d ""
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v HWAddress /t REG_SZ /d ""
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v PortNumber /t REG_DWORD /d 9100
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v "SNMP Community" /t REG_SZ /d ""
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v "SNMP Enabled" /t REG_DWORD /d 00000000
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v "SNMP Index" /t REG_DWORD /d 00000001
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\MICR1" /v PortMonMibPortIndex /t REG_DWORD /d 00000000
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now