JSI Tip 10625. How can I change the subnet mask on all the workstations and member servers of my domain?

I have scripted MbrSNM.bat to change the subnet mask on all the workstations and member servers of the domain you are logged onto.

The syntax for using MbrSNM.bat is:

MbrSNM Interface NewSubnetMask Account Password


Interface     is the name of the interface you wish to configure.

NewSubnetMask is the new subnet mask for the Interface interface.

Account       is an account that has administrative privileges on all members, like Administrator.

Password      is the password for Account.
NOTE: MbrSNM.bat uses the following programs and scripts, which must be present in the PATH of the computer you use to run the script:
       NETDOM.EXE   from the Support Tools of your operating system CD-ROM.

       NetSh.exe    see tip 10621 » How can I display the IP configuration information for a specific interface?

       PsExec.EXE   from tip 4141 » PsExec freeware executes programs remotely.

       CMPAvail.bat from tip 9825 » Another way to test the availability of a remote computer.
                    Because of CMPAvail.bat, you must run the MbrSNM.bat script from Windows XP,
                    or Windows Server 2003, or later.
MbrSNM.bat contains:
@echo off
if \{%4\}==\{\} @echo Syntax: MbrSNM Interface SubNetMask Account Password&goto :EOF
set Intrf=%1
set NewSNM=%2
set usr=%3
set pw=%4
set netdm=netdom query /domain:%userdnsdomain% workstation
set fnd=FIND /i /v "The command completed successfully."
@echo.set IP=NONE>>"%TEMP%\MbrSNM.bat"
@echo.for /f "Tokens=3 Delims=: " %%%%a in ('netsh interface ip show config %intrf%^^^|find "IP Address"') do (>>"%TEMP%\MbrSNM.bat"
@echo. set IP=%%%%a>>"%TEMP%\MbrSNM.bat"
@echo.netsh interface ip set address %Intrf% static %%IP%% %NewSNM%>>"%TEMP%\MbrSNM.bat"
for /f "Skip=1 Tokens=*" %%C in ('%netdm%^|%fnd%') Do call :mbr1 %%C
if exist "%TEMP%\MbrSNM.tmp" del /q "%TEMP%\MbrSNM.tmp"
if exist "%TEMP%\MbrSNM.bat" del /q "%TEMP%\MbrSNM.bat"
goto :EOF
call CMPAvail %1 OK
if "%OK%" EQU "Y" goto mbr2
@echo Computer %1 is not available.
goto :EOF
set cmp=\\%1
if exist "%TEMP%\MbrSNM.tmp" del /q "%TEMP%\MbrSNM.tmp"
call :mbr3>nul 2>&1
if not exist "%TEMP%\MbrSNM.tmp" goto :EOF
set GOOD=N
for /f "Tokens=*" %%x in ('type  "%TEMP%\MbrSNM.tmp"^|find "Ok."') do (
 set GOOD=Y
@echo "%cmp%","%GOOD%"
if exist "%TEMP%\MbrSNM.tmp" del /q "%TEMP%\MbrSNM.tmp"
goto :EOF
psExec %cmp% -u %usr% -p %pw% -c "%TEMP%\MbrSNM.bat">"%TEMP%\MbrSNM.tmp"

TAGS: Windows 8
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.