Rmtshare Output

  • Thread starter Thread starter Barney
  • Start date Start date
B

Barney

I'm trying to use the rmtshare utility (output below) and
a for statement to parse out just the share name but am
having troubles because 1. The name is variable and may
or may not include spaces. 2. The resource path may be
D:\ E:\ F:\ but I can't seem to specify these strings as
Delims.

Any ideas?


Share name Resource Remark
 
I'm trying to use the rmtshare utility (output below) and
a for statement to parse out just the share name but am
having troubles because 1. The name is variable and may
or may not include spaces. 2. The resource path may be
D:\ E:\ F:\ but I can't seem to specify these strings as
Delims.

Any ideas?


Share name Resource Remark

----------------------------------------------------------
ShareName D:\FolderName Comment Data
ShareName With Spaces
E:\NewName Another
Comment
The output of RMTSHARE is columnular

@echo off
setlocal ENABLEDELAYEDEXPANSION
set fnd="The command completed successfully."
for /f "Skip=4 Tokens=*" %%a in ('rmtshare \\JSI001^|Findstr /V %fnd%') do (
set line=%%a
set shr=!line:~0,13!##
set rsc=!line:~13,32!##
set rmk=!line:~45!##
set shr=!shr: =!
set shr=!shr: ##=!
set shr=!shr:##=!
set rsc=!rsc: =!
set rsc=!rsc: ##=!
set rsc=!rsc:##=!
set rmk=!rmk: =!
set rmk=!rmk: ##=!
set rmk=!rmk:##=!
@echo Share=!shr!
@echo Resce=!rsc!
@echo Remrk=!rmk!
@echo.
)
endlocal


Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
 
Hi Jerold

Sincere thanks. This is certainly close to working.
Where do the values 13,32,45 come from? Am I supposed to
replace them with values 'appropriate' for our servers?
i.e., We have shares whose names exceeds 13 characters -
do I replace 13 with the longest share name we have?
-----Original Message-----
The output of RMTSHARE is columnular

@echo off
setlocal ENABLEDELAYEDEXPANSION
set fnd="The command completed successfully."
for /f "Skip=4 Tokens=*" %%a in ('rmtshare
\\JSI001^|Findstr /V %fnd%') do (
 
See tip 9102 in the 'Tips & Tricks' at http://www.jsiinc.com for an updated script and explanation.
There is no need to update anything in the new script.
The script does assume that there is no spaces in a computer name or a share name.




Hi Jerold

Sincere thanks. This is certainly close to working.
Where do the values 13,32,45 come from? Am I supposed to
replace them with values 'appropriate' for our servers?
i.e., We have shares whose names exceeds 13 characters -
do I replace 13 with the longest share name we have?
-----Original Message-----


Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top