Solved

Creating an interactive script

Posted on 2010-08-23
2
757 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you considered what group policies are backwards and forwards compatible? Windows Active Directory servers and clients use group policy templates to deploy sets of policies within your domain. But, there is a catch to deploying policies. The…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 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