Jump to content

Unattended Batch Scripts


rathcoffey

Recommended Posts

Hi all

I have a query that I hope somone can help with.

Within the WAN I maintain, there are multiple subnets i.e. 192.168.1.X ...... 192.168.2.X

I would like to know is it possible to have the script I use when my unattended WinXp installation is finished to look at what subnet its on and call on a script to install the software from a specific location. i.e. If subnet=192.168.2.X then run InstallA.bat, if subnet=192.168.3.X then run InstallB.bat and so on.

Any ideas or help greatly appreciated.

Thanks

Rathcoffey

Link to comment
Share on other sites


A simple batchfile to determine which network you are in. Note that the goto :EOF isn't needed here as you don't return to this script after executing the InstallX.bat batch file. If you need to return use "call InstallX.bat" in place of "InstallX.bat".

@echo off

ipconfig | find "IP Address" | find "192.168.1." >nul:

if not errorlevel 1 (

echo In 192.168.1.x network

InstallA.bat

goto :EOF

)

ipconfig | find "IP Address" | find "192.168.2." >nul:

if not errorlevel 1 (

echo In 192.168.2.x network

InstallB.bat

goto :EOF

)

If you are installing the same software but from a different location you could replaxe the InstallX.bat with a net use command to map the network drive.

@echo off

ipconfig | find "IP Address" | find "192.168.1." >nul:

if not errorlevel 1 (

echo In 192.168.1.x network

net use z: \\server\share

goto :Install

)

ipconfig | find "IP Address" | find "192.168.2." >nul:

if not errorlevel 1 (

echo In 192.168.2.x network

net use z: \\server\share

goto :Install

)

:Install

rem install softeare here

rem delete mapped drive

net use z: /delete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...