?
Solved

Creating an interactive script

Posted on 2010-08-23
2
Medium Priority
?
769 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 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