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.
November 30, 2005
I have scripted OLCNS.BAT to output, in CSV format, the offline cache settings for my shares, by parsing the output of the net share command.
The syntax for using OLCNS.BAT is:
OLCNS
Output is displayed on the console in the following format:
"Share Name","File System Path","Cache Setting"Where Cache Setting can be one of the following:Manual caching of documentsAutomatic caching of documentsAutomatic caching of programs and documentsCaching disabled.
OLCNS.BAT contains:
@echo offsetlocal ENABLEDELAYEDEXPANSIONset f1=Findstr /l /n /v /c:"*$"set f2=Find /V "The command completed successfully."for /f "Skip=4 Tokens=1* Delims=:" %%a in ('net share ^|%f1%^|%f2%') do ( set line=%%b if "!line:~0,1!" NEQ " " call :parse %%b)endlocalgoto :EOF:parseif "%1" EQU "" goto :EOFset sn=%1set sp=set cc=call :parse1 %1if "%sp%" EQU "" goto :EOFif "%cc%" EQU "" goto :EOFif "%sp:~1,1%" NEQ ":" goto :EOF@echo "%sn%","%sp%","%cc%"goto :EOF:parse1for /f "Tokens=*" %%x in ('net share %1') do ( set line=%%x if "!line:~0,18!" EQU "Path " set sp=!line:~18! if "!line:~0,18!" EQU "Caching " set cc=!line:~18!)
You May Also Like