Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


December 1997

Reader to Reader - December 1997

RSS
Subscribe to Windows IT Pro | See More Windows NT 4.0 Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Being a Windows NT enthusiast, I enjoy getting as much mileage out of native commands and utilities as I can, especially at the command line. I hate hearing that I can't carry out a command that the UNIX world considers stock-in-trade.

This passion came in handy recently. An administrator was making rounds at midnight to reboot machines so that a backup could catch files that were still open. I was helping close files after hours, and I came up with an idea: A scheduled batch file could automatically close open files. Much to the administrator's surprise (this person had a UNIX background), I put the following command in a batch file:

for /f "skip=4 eol=T" %%i in ('net file') do net file %%i /close

The /f option parses output, and for this example, passes the first white-spaced token on to the rest of the line. (Other tokens can pass.) The eol=T keeps the command from generating an annoying message when fed an empty line. You need the double percent signs for shell variables inside batch files.

You can then use an at command to schedule when the batch file will run:

at 01:00 /every:m,t,w,th,f d:\users\davidk\kill_open_files.bat

An alternative way to perform this process is through Control Panel, Server, but you can't schedule the process if you use this method. So try a "for /?" sometime and get familiar with its options. It's a useful, robust command.


Use Your Dial-Up Monitor Icon Effectively
When the Microsoft Internet Mail program starts a dial-up connection, the Dial-Up Monitor icon does not show up in the tray bar. If you need the icon, start any dial-up connection that uses the same port. It won't dial, alerting you that the port is in use. Clicking Cancel will stop the dialing, but the Dial-Up Monitor will surface in the tray bar.

You can also use a shortcut to quickly hang up a connection. Usually, you right-click the Dial-Up Monitor icon in the tray bar, choose Hang-Up, choose the connection, and click OK. But if you double-right-click the icon and click OK, you shut down all the connections at once.


Automate for Easy Installation
I recently installed a large NT 4.0 network with out-of-the-box Dell computers. The computers came preinstalled with NT Workstation 4.0. But when I turned on the power, I found that they required a lot of data input and protocol changes to suit my environment.

I came up with an easy solution to automate installation. I found the NT unattended configuration file, winnt.sif, in the hidden subdirectory $win_nt$.~bt on the c: drive. I modified this file to meet my needs (you can find documentation on all parameters at Microsoft's Web site, http://www.microsoft.com/exchange) and saved it to multiple subdirectories on a bootable floppy. Then, in each file, I changed ComputerName to a unique name. Finally, I created a batch file to copy the appropriate file to c:\$win_nt$.~bt.

This solution made installation easy. After hooking each new PC to the network, I booted it with my floppy, typed INSTALL "workstation name" to copy my winnt.sif file over the Dell file, removed the floppy, and rebooted the PC. I was in business!


The Solution Might Be Right in Front of You
How many times has a solution for a problem come along at just the right time (and at the right price--free)? Although this timing doesn't happen often, the solution might be right before your eyes this time. I had initially missed this solution, even though I had looked through the Microsoft Windows NT Server Resource Kit a hundred times. It had been in the kit's \KIX95 subdirectory all along. It is KiXtart.

KiXtart is a 32-bit freeware application that performs logon-script and enhanced batch-file processing. You can find it in the Resource Kit or on The KiXtart Archive Web site at http://netnet.net/~swilson/kix/. With KiXtart, you can connect to network drives, set variables, and read and write to the NT Registry. If you require custom functionality but lack strong programming skills, KiXtart is a simple, but powerful tool for network management.

I used KiXtart to solve a problem that involved using FTP with a script file to copy files for the current date. I used the FTP command, MGET, to transfer on wild card filenames (e.g., mget *970725*). Initially I had planned to use a batch scheduler to run this command every day. But I realized that this approach would require me to edit the script file daily to correct the date or copy all files, which would consume bandwidth. There had to be a better way. That's when I discovered KiXtart.

I configured KiXtart to take the current date, reformat the date to correspond to the required file syntax, write the new format to the FTP script file (ftpscr.txt), and execute the FTP command from within the script file. Listing 1 contains the FTP script file. After testing the KiXtart script (when working with the NT Registry, you must test any script before implementing it), I ran it. It worked so well that I used KiXtart to solve several problems with dates:

* The wild card requires a two-digit month to copy the filenames. But the output for July was 7 instead of 07. So I used the IF-ELSE-ENDIF command to add "0" if @MONTHNO was less than 10. (KiXtart uses handy common macros such as @MONTHNO.)

* The @DATE macro output was yyyymmdd, but the wild card accepts only a two-digit year. So I used the SUBSTR and LEN functions to send only the last two digits to the script file.

* The REDIRECTOUTPUT function requires an IF-ELSE-ENDIF command to prevent writing a successful 0 result code as text on the first line of the ftp scr.txt file

I used the syntax \\server\sharename\kix32.exe makefile.scr for these solutions. Listing 2, page 38, contains the script.

   Previous  [1]  2  Next 


Top Viewed ArticlesView all articles
CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

Where is Microsoft NetMeeting in Windows XP?

...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing