ITProOnTheGo
asked on
Need a script to disable caching on thousands of shares
How do I write a script that will run "net share sharename /cache:none" against thousands of sharenames? I have a list of the sharenames in a file, I just don't want to run these manually and I am not a scripter.
Well it is not asy to write a batch file that will do what you need, without you sharing a sample the your file. Does not have to be the exact data.
Anyway, here is a very simplistic batch file that will do what you need, but, will most likely not work as is because, i have no clue what you data file is made of.
Anyway, here is a very simplistic batch file that will do what you need, but, will most likely not work as is because, i have no clue what you data file is made of.
@ECHO OFF
REM assuming your data file format is; computer,sharename
FOR /F "usebackq tokens=1,2 delims=," %%A in ("datafile.txt") DO (
ECHO For Computer [%%A] at sharename [%%B]
psexec %%A net share %%B /cache:none
)
PAUSE
EXIT
Why don't you take your list, and edit the beginning and end of the lines so that they match the command you are trying to run? I like to use Excel to get it all into easily columns for easy editing. Then you can just save the file as a text file with .cmd extension. Then just run the file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help.
Open in new window