[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Creating an interactive script

Posted on 2010-08-23
2
Medium Priority
?
774 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

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 here: http://www.experts-exchang…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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