Solved

Creating an interactive script

Posted on 2010-08-23
2
744 Views
Last Modified: 2013-11-25
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
Comment
Question by:sedberg1
2 Comments
 
LVL 12

Expert Comment

by:Gary Dewrell
ID: 33501244
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
 

Accepted Solution

by:
sedberg1 earned 0 total points
ID: 33501602
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found listed in my profile here: http:…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now