[windows2000] Re: Upgrade win2k pro to win2k server?

  • From: "Sullivan, Glenn" <GSullivan@xxxxxxxxxxxxxx>
  • To: "'windows2000@xxxxxxxxxxxxx'" <windows2000@xxxxxxxxxxxxx>
  • Date: Wed, 7 May 2003 14:15:37 -0400

Sure... a simple modification of the first script...

First off, on the server in question, at a command prompt, type "net file"
and take note of how the file in question appears in the list.  
Change line number 14 to have the file name as displayed by Net File, padded
out with spaces to a length of 40 characters.

FYI, the first script simply does a NET SESSION command, looks at the "IDLE"
column, and closes those sessions where Idle is not 0.
The second script does a NET FILE command, looks at the "File Name" column,
and if it is the right file, closes it.

<-------------start script------------>
1. @Echo Off
2. setlocal
3. for /f "skip=4 tokens=1 delims=" %%i in ('net file') do call :Process
"%%i"
4. goto :EOF
5. 
6. :Process
7. if %1=="The command completed successfully." goto :EOF
8. if %1=="There are no entries in the list." goto :EOF
9. set @Line=%~1
10. set @File=%@Line:~1,40%
11. set @ID=%@lINE:~0,7%
12. rem Change this line to have the file in question, padded out to 40
characters
13. if "%@File%"=="c:\scripts\test.cmd                     " net file %@ID%
/close
14. Endlocal
<--------End Script--------->

Hope this helps,

Glenn Sullivan, MCSE+I  MCDBA
David Clark Company Inc.


-----Original Message-----
From: Chris Berry [mailto:compjma@xxxxxxxxxxx]
Sent: Wednesday, May 07, 2003 2:00 PM
To: windows2000@xxxxxxxxxxxxx
Subject: [windows2000] Re: Upgrade win2k pro to win2k server?



>From: "Sullivan, Glenn" <GSullivan@xxxxxxxxxxxxxx>
>Here is a .cmd script that you could schedule to run every so often... it
>disconnects all sessions that have an "Idle" value of more than 0.
>
>Be careful of line wrap... I am going to number each line.  Remove the
>number, the period, and the space at the beginning of each line, and save 
>it
>as a .CMD file.  Line 5 is intentionally left blank...
>
><------------Start Script------------>
>1. @Echo Off
>2. setlocal
>3. for /f "skip=4 tokens=1,4 delims=" %%i in ('net session') do call
>:Process "%%i"
>4. goto :EOF
>5.
>6. :Process
>7. if %1=="The command completed successfully." goto :EOF
>8. set @Session=%~1
>9. set @Computer=%@Session:~0,17%
>10. set @Idle=%@Session:~62,5%
>11. if not "%@Idle%"=="    0" net session %@Computer% /DELETE
>12. Endlocal
><------------End Script--------------->

That's pretty cool Glenn, do you know how to close open files on network 
shares programatically?  I have this app called InfoUSA that has a messed up

license checking routine, every day or two I have to go into computer 
management and close all the connections to the license file, then restore 
that file from a backup copy.  I'd like to write myself a script to do this,

but I don't know how to access the open files interface from the command 
line.  Anyone have an idea?

Chris Berry
compjma@xxxxxxxxxxx
Systems Administrator
JM Associates

"This email is ROT26 encrypted, by reading it you are in violation of the 
DMCA, and should turn yourself in to the authorities immediately."

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*  
http://join.msn.com/?page=features/virus


==================================
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm

==================================
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm

Other related posts: