• subscribe
December 01, 1997 12:00 AM

Reader to Reader - December 1997

Windows IT Pro
InstantDoc ID #3550

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.



ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...