Listing 3: Modified Logshares.bat Script @echo off goto begin rem //////////////////////////////////////////////////////// rem File: LOGSHARES.BAT rem Author: Douglas L. Gillett-MCSE,MCP+Internet rem Copyright 1998 Douglas L. Gillett rem Date: 27 May, 1998 rem Purpose:This batch file should be run as a scheduled rem task from an NT Domain Member with privileges to rem view shares and permissions on each domain NT rem server and NT workstation. It is recommended rem that this batchfile be run once per week to rem maintain a current log of share permissions, rem should they ever need to be reapplied. rem //////////////////////////////////////////////////////// :begin rem ! Let's get the current date and use it as part of the rem ! logfile name so we don't overwrite the last logfile. rem ! This will turn our date into YYYYMMDD format and rem ! append "shares.log" to the end of it to make a unique rem ! name. :getdate for /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do ( set logdate=%%k%%i%%jshares.log ) rem ! To avoid a runaway logfile, we'll delete any logfile rem ! with the same name. This will overwrite a logfile rem ! created on the same day. :dellog if exist %logdate% del %logdate% rem ! Now let's run the NT Resource Kit utility "srvcheck" rem ! against each of the domain servers and workstations. rem ! We will use the "net view /domain:domainname" command rem ! inside of a "for" statement to get a list of all the rem ! servers and workstations. We'll output the results rem ! of the "srvcheck" command to our logfile using the rem ! name we created above. In addition we'll put in some rem ! echos to create a nicely formatted log. rem ! NOTE: "ECHO:" outputs a blank line. :logshares for /f "tokens=1 skip=3 eol=T" %%i in ('net view /domain:genisys') do ( echo: 1>>%logdate% echo: 1>>%logdate% echo: 1>>%logdate% echo :==========================================================: 1>>%logdate% echo SHARES LISTING FOR [%%i] 1>>%logdate% echo :==========================================================: 1>>%logdate% echo SHARENAME USER/GROUP PERMISSION 1>>%logdate% echo ----------- ---------------- ----------------------------- 1>>%logdate% srvcheck %%i 1>>%logdate% 2>>&1 ) rem ! Now that we're done using our logfile name, we should rem ! clear it from the environment variable listing. :clearname set logdate= :deloldlogs rem ! 06-Nov-1998 revision Bruce A. Edmondson rem ! To prevent the disk from filling up with log files. rem ! The newest five log files are preserved. for /f "skip=5 " %%i in ('dir /b /o:-d *.log') do (del %%i) :end