JSI Tip 10005. How can I enumerate the shares on a specified computer in delimited format?

Using RMTShare.exe, I have scripted DelimShares.bat to output the share information of a specified computer is semi-colon (;) delimited format, like:

"ShareName";"Path";"Remarks";"Maximum Number Users";"Current Number Users";"User1:Perm1";"User2:Perm2";"UserN:PermN"
Here is a partial sample"
"\\jsi001\C$";"C:\";"Default share";"No limit";"0"
"\\jsi001\NETLOGON";"C:\WINDOWS\sysvol\sysvol\JSIINC.ORG\SCRIPTS";"Logon server share";"No limit";"0";"\Everyone:READ";"BUILTIN\Administrators:FULL CONTROL"
"\\jsi001\HP2250";"HP Business Inkjet 2250 (PCL5C),LocalsplOnly";"Fastest";"No limit";"0";"BUILTIN\Administrators:FULL CONTROL";"UserX:PermX"
The syntax for using DelimShares.bat is:

DelimShares \\ComputerName

Where \\ComputerName is a remote or local computer name.

DelimShares.bat contains:

@echo off
if \{%1\}==\{\} goto err
set comp=%1
if "%comp:~0,2%" NEQ "\\" goto err
set f1=find /v "The command completed successfully."
set f2=findstr /v /b /c:"Share name"
set f3=find /v "--------------"
set f4=find /v "No permissions specified."
set f5=find /v "Permissions:"
for /f "Tokens=1" %%a in ('rmtshare %comp%^|%f1%^|%f2%^|%f3%') do (
 set shr=%%a
 call :sharename
goto :EOF
set perm=
for /F "Tokens=*" %%s in ('rmtshare %comp%\%shr% ^|%f1%^|%f4%^|%f5%') do (
 set work=%%s
 set work=!work:;=,!
 if "!work:~0,18!" EQU "Share name        " set sn="!work:~18!"&set work=NONE
 if "!work:~0,4!" EQU "Path" set pth="!work:~18!"&set work=NONE
 if "!work:~0,6!" EQU "Remark" set rmk="!work:~18!"&set rmk=!rmk:;=,!&set work=NONE
 if "!work:~0,18!" EQU "Maximum users     " set mu="!work:~18!"&set work=NONE
 if "!work:~0,18!" EQU "Users             " set nu="!work:~18!"&set work=NONE
 if "!work!" NEQ "NONE" set work=!work:  =!
 if "!work!" NEQ "NONE" set work=!work: :=:!
 if "!work!" NEQ "NONE" set work=!work:: =:!
 if "!work!" NEQ "NONE" set perm=!perm!;"!work!"
@echo %sn%;%pth%;%rmk%;%mu%;%nu%%perm%
goto :EOF
@echo DelimShares \\ComputerName

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.