Page 1 of 1 1
Topic Options
#122786 - 2004-07-13 02:13 PM Disable caching for share
rji Offline
Fresh Scripter

Registered: 2003-01-13
Posts: 5
Loc: UK
Can anybody give me some help with creating a script to disable caching for home folder shares. An MS article resolutions says to run the following "net share sharename /cache:no" this works. But I have 1500 shares to do this for. All of the shares are located within \\server\data\users can anybody give me some points to create a script.

thanks very much

Top
#122787 - 2004-07-13 02:20 PM Re: Disable caching for share
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
WSHPIPE() UDF would probably be your friend here..

NET SHARE to list the shares using SPLIT

Then as SHELL to the individual NET SHARE stuff..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#122788 - 2004-07-13 02:22 PM Re: Disable caching for share
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the share control is also in registry.
but, quess it's easier to do this if you are on the computer.

by any means, list the shares...
like:
net share > list.txt

clean the file and do some:
do
$line=readline()

stuff.
_________________________
!

download KiXnet

Top
#122789 - 2004-07-13 10:30 PM Re: Disable caching for share
rji Offline
Fresh Scripter

Registered: 2003-01-13
Posts: 5
Loc: UK
Sorry, I am really new at kix scripting. I searched through previous threads looking for info on $line = readline(1). The follow script below reads each line from my csv file. Is there anyway of after reading each line to run the net share sharename /cache:no etc.

thanks v much

break on
$filename = "d:\shares1.csv"
if open(1,$filename) = 0
$line = readline(1)
while @error = 0
$array = split($line,",")
?
for each $field in $array
? $field
next
$line = readline(1)
loop
$= close(1)
endif
exit 1

Top
#122790 - 2004-07-14 10:11 AM Re: Disable caching for share
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Is there anyway of after reading each line to run the net share sharename /cache:no etc




Sure, use "SHELL" to run a command. Something like this (untested):

Code:
Break ON
$=SetOption('Explicit','ON')
$=SetOption('WrapAtEOL','ON')

Dim $sFilename,$aRecord,$sDatum,$sLine,$fh

$sFilename = 'd:\shares1.csv'
$fh=FreeFileHandle()

If Open($fh,$sFilename)
'Cannot open '+$sFilename+' for reading'+@CRLF
'Reason: ['+@ERROR+'] '+@SERROR+@CRLF
Exit @ERROR
Else
$sLine = Readline($fh)
While Not @ERROR
$aRecord=Split($sLine,',')
For Each $sDatum in $aRecord
'Running command on '+$sDatum+'...'
Shell 'net share '+$sDatum+' /CACHE:NONE'
If @ERROR
'Failed with: ['+@ERROR+'] '+@SERROR+@CRLF
EndIf
@CRLF
Next
$sLine=Readline($fh)
Loop
$=Close($fh)
EndIf



Not knowing what your CSV file looks like I can only guess from your original code what you want to run the command on.

If is it only supposed to be run once per line, collapse the "For Each" loop and use $aRecord[X] rather than $sDatum in the SHELL command, where "X" is the array element that contains the share name.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.053 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org