
AlphaSure Ltd. 41 Walpole Road London E18 2LN United Kingdom
| |
|
|
|
Simple batch files *.bat files
(Yes, this is old, but it reference for those that still have old systems).
This very useful command can be used to schedule all sorts of things from Defragging drives, to performing backups, stopping services on servers, etc.
One way is to create a batch file (*.bat) which does the relevant job. (There are more powerful tools built in to server to do this, but are far more complex to use than this simple task).To do this, you need to do the commands as in DOS. Those exact commands are typed (or copied and pasted) into your batch file.
So, for example, you have a folder on H Drive called "Retrospect Catalog" which you need to copy onto your C Drive every day (as your C Drive automatically gets backed up, whereas H Drive does not). These copied files need to be placed in a folder called "retrocpy" on C Drive, which you have already manually created. This is how it is done under DOS, the copy /V/Y commands are to verify the copy (/V) and to overwrite existing files without asking (/Y).
The batch file is made of the exact same commands:
h: cd\retros~1 copy *.* c:\retrocpy /V/Y Open Notepad (Start Menu/ Programs/ Accessories/Notepad) which is a simple text editor. Type these same commands into Notepad and save them. However, DO NOT save them a a text file (*.txt). Instead on the bottom, where it says "type", click on there and choose "All Files *.*" Then in the space above type the name of the script and end it with .bat, so in this case "copyret.bat" Click here to download the above example
So any commands you need to do (even on a remote computer) can all be saved in a single batch file and run as one job. In my case I saved it on the desktop and double click it every time it needs to be run. But, it can be automated via the AT command to run at a specific time, or on specific days. Click here.
Example 1: When shutting down a Windows 2000 Advanced Server,running as Web Server only run this batch file first, then go to the Start Menu and Shutdown. You will find on bigger servers it can cut the shutdown time by 15 minutes. It doesn't include any Exchange services stopping, which you need to add if you are running Exchange on the same server (by doing so you will save another 15-20 minutes if you are running both on the same server.)
NET STOP Alerter NET STOP Automatic Updates NET STOP AutoTask NET STOP Background Intelligent Transfer Service NET STOP "Com+ Evenet System" NET STOP Computer Browser NET STOP DHCP Client NET STOP Distributed File System NET STOP Distributed Link Tracking Client NET STOP Distributed Transaction Coordinator NET STOP DNS Client NET STOP File Server for Macintosh NET STOP FTP Publishing Service NET STOP IIS Admin Service NET STOP Indexing Service NET STOP Internet Authentication Service NET STOP Licence Logging Service NET STOP Logical Disk Manager NET STOP Machine Debug Manager NET STOP Messenger NET STOP Net Logon NET STOP Network Connections NET STOP "Network News Transport Protocol(NNTP)" NET STOP pcAnuwhere Host Service NET STOP Persits Software EMail Agent NET STOP Plug and Play NET STOP Print Server for Macintosh NET STOP Print Spooler NET STOP Protected Storage NET STOP Remote Access Connection Manager NET STOP "Remote Procedure Call (RPC)" NET STOP "Remote Procedure Call (RPC) Locator" NET STOP Remote Registry Service NET STOP Removable Storage NET STOP Routing and Remote Access NET STOP RunAs Service NET STOP Security Accounts Manager NET STOP Server NET STOP "Simple Mail Transport Protocol (SMTP)" NET STOP "Simple TCP/IP Service" NET STOP Site Server ILS Service NET STOP SNMP Service NET STOP Task Scheduler NET STOP System Event Notification NET STOP Task Scheduler NET STOP "TCP/IP NetBIOS Helper Service" NET STOP "TCP/IP Print Server" NET STOP Telephony NET STOP Telnet NET STOP Terminal Services NET STOP Terminal Services Licensing NET STOP Windows Management Instrumentation NET STOP Windows Management Instrumentation Driver Extensions NET STOP Windows Time NET STOP World Wide Web Publishing Service
Click here to download the above example Example 2.
To start the same services up, put the above example into word and change "STOP" to "START" for all occurrences, and then put it into a batch file. You will be able to start all the services with double clicking a single file.... Click here to download Example 2
Example 3
You want all local machines to be set to the same time as the server fileserver, create a batch file with this entry:
NET TIME \\FILESERVER /SET /Y
and each computer it is run on will synchronise with FILESERVER. Use the AT command to set it each night, and this will ensure your logs remain accurate across machines.
Example 4 Simple backup using NT Backup.exe on a tape storage device and to eject the tape at the end
The batch file contains:
ntbackup backup c: /t normal /b /l"c:\backup.log"
ntbackup eject
and backs up drive c to the tape drive, putting a log file of c:\backup.log in text format. NOTE that on Windows 2000/2003, this task is much easier to accomplish using the Scheduler.
|