Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

March 08, 2000 09:46 AM

Resource Kit Batch File Commands

Windows IT Pro
InstantDoc ID #8315
Rating: (0)

In this installment of Top 10, I share my favorite Microsoft Windows NT Server 4.0 Resource Kit commands, which I frequently use with my NT command shell scripts. Choosing only 10 commands is difficult because the resource kit provides a rich selection of utilities. (Check out Mark Minasi's This Old Resource Kit columns for more information about resource kit tools.)

10. AutoExNT lets you start the NT command autoexnt.bat when your system boots up, without requiring the user to log on to the system. You use the Instexnt install command to install AutoExNT. To make the service start automatically, go to the Control Panel Services applet and set AutoExNT's startup option to Automatic.

9. AddUsers lets you add and delete user accounts. The command, which you can use for local and remote accounts, reads the account names from a comma-delimited file. Here's how to use AddUsers to add accounts from the accounts.txt file to the system named MyServer:

addusers //MyServer /c accounts.txt

8. IfMember, a useful addition to your logon scripts, lets your scripts take action if a particular user belongs to a specific group. Here's how to use IfMember to determine whether the current user is part of the Administrators group:

ifmember Administrators
if errorlevel 1 echo The user is in the Administrators group

7. LogEvent lets your NT command script write entries into a local or remote NT system's application event log. Here's how to use LogEvent to write an information message:

logevent "Batch Job Completed"

6. Dumpel lets you dump event-log contents to a text file, which you can then process using commands such as For, Findstr, and Munge. Here's how to dump MyServer's system event log to the myevents.txt file:

dumpel -f C:\temp\myevents.txt -s MyServer -l system

5. Munge lets you find and replace strings in text files. Munge is handy because it lets you update your batch files when you need to make mass changes to several scripts. The command uses a script file that contains the from and to strings that will change. Here's how to update the myscript.cmd file using the strings contained in the file changes.txt:

munge changes.txt myscript.cmd

4. Robocopy can copy a single file, multiple files (using wildcards), and full directory trees. Robocopy's ability to retry after network errors makes it superior to NT's standard Copy command. Here's how to copy a directory named scripts from MyServer1 to MyServer2:

robocopy "//MyServer1\scripts" "//MyServer2\scripts"

3. Choice presents a simple set of choices to the end user. Windows 9x includes Choice in its command shell, but the command is missing in NT. Fortunately, its inclusion in the resource kit lets you use Choice in your NT command scripts. Here's a typical example of how to use Choice:

choice Enter Y to Run or N to Cancel

2. Now displays the current date and time. When you use Now in conjunction with redirection, you can log the completion of scripts. Here's how to use Now to write a time-stamped entry into a file named mylog.txt:

now command script completed>mylog.txt

1. Sleep and TimeOut are two of the resource kit's most vital batch file commands. Both commands let your NT command script suspend execution for a set time period (e.g., 60 seconds):

sleep 60
timeout 60

TimeOut resumes execution when the user presses any key.

Related Content:

ARTICLE TOOLS

Comments
  • Anonymous User
    8 years ago
    Dec 12, 2004

    i ment my school

  • Anonymous User
    8 years ago
    Dec 12, 2004

    if any one can tell me how to hack into my using only the I.P or computer name please e-mail me at bli0001@ballaraths.vic.edu.au

  • stephen
    8 years ago
    Jun 10, 2004

    I am running a program with a batch file and am left with an open dos window, I would like to leave the program running and minimize the dos window to the taskbar, am running windows 2000

  • Michael
    8 years ago
    Jun 10, 2004

    I'm trying to create to batch file that would be started in a scheduled task. My question is how can I loop the batch file to run until it finds the file(s) needs then end once the task is done. For example: The scheduled task is for 1am but the files comes in later @ 1:30am.
    How can I make the batch file loop until the file(s) needed arrive? Thank you.

  • TP
    8 years ago
    May 29, 2004

    Ray, if you haven't already figured, re: " to copy a big file in a window 2000 environment and name it to the date it was done"...
    1- per Regional in Control Panel, set the date delimiter to "-" (dash).
    2- copy NeededFile.ext %date%.ext
    That will copy as desired. HTH!

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.