Using Batch Files To Automate Repetitive NetworkingLast reviewed: March 18, 1998Article ID: Q173529 |
The information in this article applies to:
SUMMARYThis article demonstrates a few ways to use Windows NT command extensions in conjunction with Windows NT Resource Kit utilities within batch files to automate common networking tasks. The following tasks will be illustrated:
How to Automate the Addition of Domain\Domain UsersHow to automate the addition of "Domain\Domain Users" global group to each of the member servers "Change the system time" user right.
echo off cls echo Creating a list of member servers. echo. netdom member > netdom.txt echo Adding "Change System Time" right to Member Servers... echo. if exist log.txt del log.txt for /F "skip=6 delims= tokens=4" %%a in (netdom.txt) do call ADDTIME2.bat %%a rem The line above must have two spaces between delims= tokens=4. echo. echo ---------------------------------------------- echo - Done! Check LOG.TXT for status information.- echo ---------------------------------------------- Filename: ADDTIME2.BAT echo Adding right to %1... ntrights -u "domain users" -m %1 +r SeSystemTimePrivilege >> log.txt
How to Add Files to Many Users' Home DirectoriesTo add files to many users' home directories, perform the following steps:
echo off cls IF (%1)==() GOTO NoParams IF (%2)==() GOTO NoParams Echo Creating directory listing... dir %1 > dir.txt for /F "skip=7 delims= tokens=4" %%a in (dir.txt) do call addfile2.bat %%a %1 %2 rem The line above must have two spaces between delims= tokens=4. echo --------- echo - Done! - echo --------- GOTO Bottom :NoParams ECHO usage: ADDFILE [Parent Directory] [File to Add] ECHO. ECHO i.e.- ADDFILE C:\PROFILES MyFile.lnk ECHO. :Bottom Filename: ADDFILE2.BAT if (%1)==() goto bottom if (%1)==(bytes) goto bottom copy %3 %2\%1 :bottom
How to Restart Services On All Domain Controllers Within a DomainTo restart service on all domain controllers within a domain, perform the following steps:
echo off cls if (%1)==() goto NoParams netdom bdc > netdom.txt for /F "skip=6 delims= tokens=4" %%a in (netdom.txt) do call restart2.bat %%a %1 rem The line above must have two spaces between delims= tokens=4. echo --------- echo - Done! - echo --------- goto bottom :NoParams echo usage: RESTART "Service Name" echo. echo. i.e.- RESTART "License Logging Service" echo. :bottom Filename: RESTART2.BAT echo Restarting %2 on %1 netsvc %2 %1 /stop netsvc %2 %1 /start echo.
|
Additional query words: Iterative Processing script
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |