JSI Tip 8397. How can a batch script determine the number of users with active connections to a server share?

Jerold Schulman

August 19, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today


If you open a CMD.EXE window, and type RMTShare \ServerNameShareName, like rmtshare \jsi001Users, you receive a display similar to:

Share name        \jsi001UsersPath              D:UsersRemarkMaximum users     No limitUsers             7Permissions:        Everyone  :  FULL CONTROLThe command completed successfully.

To extract the number of users in a batch file, use:

for /f "Tokens=1,2" %%t in ('RMTShare \ServerNameShareName^|FIND "Users"') do ( if "%%t" EQU "Users" set /a conusers=1000000%%u%%1000000)

In this example, the conusers numeric environment variable will be set to 7.

NOTE: The exact case of Users is required.



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like