Link to home
Start Free TrialLog in
Avatar of ITProOnTheGo
ITProOnTheGoFlag for United States of America

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.
Avatar of Amit Khilnaney
Amit Khilnaney
Flag of India image

I guess this question is somewhat related to this..
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Q_22544648.html

Open in new window

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.

@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

Open in new window

Avatar of kevinhsieh
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
Avatar of ReneGe
ReneGe
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad I could help.