From: Al Dunbar on


"Leon" <kim.zethsen(a)gmail.com> wrote in message
news:96e5404f-5054-407b-ae64-fc35be40a9be(a)z4g2000yqa.googlegroups.com...
> Basicly I want to monitor severel forlders on severel servers.
> In each folder I want to find the newest file - if any.
> Filename and LastModified timestamp.
>
> As network traffic slows down the proces getting information from
> names like \\server1\data\something...
> I want to make this faster
>
> F.example a cal to a certain remote folder with over 800 files takes
> severel minutes (4 to 5 minutes)

It is a lot faster to do this kind of monitoring on a local hard drive than
across a network. While it might be possible to tweak your code slightly, I
think the bottleneck here is the network, and the processing that the remote
system needs to do to accommodate the various accesses to its file system.

Think about it. You are creating an object on your local system for each of
hundreds of files that exist on a remote system. Where does this object
reside, and where do all of its attributes reside? Even if it only fetches
those attributes you request at the time the reference is made, there must
still be somewhat more I/O going on than getting a simple directory listing
for each file. Not that I am saying that that would be a better way to go...

> On local server it takes a blink of an eye..

Precisely. So why have you not followed Pegasus' advice and use psexec to
get the remote servers to do the work for you, and then simply return the
result?

> I'm using this function... (takes 5 minutes on certain folders..too
> much I think)

It might be too much time for your purposes, however, it takes the time that
it takes.

/Al

> (The timestamp array is to have full control og datetime format which
> gave me some challange in danish interpretion of month day.. )
>
>
>
> Sub CheckFolder(Fldr, mask, idx)
> NewestFileInFolder = ""
> Set oFolder =
> CreateObject("scripting.filesystemobject").getfolder(Fldr)
> For Each aFile In oFolder.Files
> If NewestFileInFolder = "" Then
> Set NewestFileInFolder = aFile
> Else
> If RegExpTest(mask, aFile.Name) Then
> If NewestFileInFolder.DateLastModified <
> aFile.DateLastModified Then
> Set NewestFileInFolder = aFile
> FileList(idx) = NewestFileInFolder.Name
> TimeStampLastModifiedArray(idx, 1) =
> Year(aFile.DateLastModified)
> TimeStampLastModifiedArray(idx, 2) =
> Month(aFile.DateLastModified)
> TimeStampLastModifiedArray(idx, 3) =
> Day(aFile.DateLastModified)
> TimeStampLastModifiedArray(idx, 4) =
> Hour(aFile.DateLastModified)
> TimeStampLastModifiedArray(idx, 5) =
> Minute(aFile.DateLastModified)
> TimeStampLastModifiedArray(idx, 6) =
> Second(aFile.DateLastModified)
>
> End If
> End If
> End If
> Next
> End Sub
>
> (This information tells me that some processes are runing as they
> suppose to do.
> some file have to be updated in certain intervals.
> Files certain folders gives me kinda status from processes..)
>
>
> On 12 Mar., 16:21, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
>> I don't quite see what your two points have to do with each other:
>> - Redirect the output from the "dir" command into a file
>> - Select a specific output format.
>>
>> To me they look completely independent. What information do you actually
>> reqjuire? Let's see an example!
>>
>> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>>
>> news:d3d1062f-436d-420f-abea-26d5c5fd99f3(a)o3g2000yqb.googlegroups.com...
>>
>>
>>
>> > Hi again
>>
>> > In order to speed up things I can see that it is faster to make a
>> > redirection of a ls or dir command to a file.
>> > Then from the file take out the last modified timestamp.
>>
>> > The thing is that dir gives some disk info.. and when adding the /b
>> > option no diskinfo is comming up BUT the time info is omitted.
>>
>> > So I need something in between.
>>
>> > On 12 Mar., 10:59, Leon <kim.zeth...(a)gmail.com> wrote:
>> >> Hi Pegasus
>>
>> >> I'll for sure try it out!!
>> >> Thanks!!!
>> >> :-)
>> >> Have a nice weekend
>> >> Go helg
>>
>> >> On 12 Mar., 00:29, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
>>
>> >> > "Leon" <kim.zeth...(a)gmail.com> wrote in message
>>
>> >> >news:f9d98c33-d656-424b-9ce5-91da71945168(a)d27g2000yqf.googlegroups.com...
>>
>> >> > > Hi guys!
>>
>> >> > > Now I was able to hit..
>> >> > > I'll try this out..
>>
>> >> > > Thanks..
>>
>> >> > > The thing is that I want to monitor sererel servers.. and want to
>> >> > > run
>> >> > > the script on a central pc.
>> >> > > s� running script remotely does not bring me closer - I think..
>> >> > > Mayby I havent got the clu - I'l invest your suggeston.
>>
>> >> > > Thanks for answering! :-)
>> >> > > Cheers
>>
>> >> > When you play with psexec.exe then you will see that you can invoke
>> >> > it
>> >> > from
>> >> > your own machine so that it runs its task on any number of remote
>> >> > machines.
>> >> > If you do it correctly then you can get each of these tasks to
>> >> > report
>> >> > its
>> >> > result on your own machine. The key is that you must play with it to
>> >> > understand it. Om du lekar med psexec en stund s� kan du snart se
>> >> > hur
>> >> > den
>> >> > funkar.- Skjul tekst i anf�rselstegn -
>>
>> >> - Vis tekst i anf�rselstegn -- Skjul tekst i anf�rselstegn -
>>
>> - Vis tekst i anf�rselstegn -
>
From: Leon on
Hi

Yes mayne it just takes the time it takes.. hmm
And why not do remote scripting..no.. I want a tool that can be
maintained without processes on every remote server .. :-)

But using DOS command speeds this task up from severel minutes to
seconds

looping through array with specified folders with VBS..

Creating bat file by code
Running bat file - writing result into a file
Overwrite bat file with new folderspec and filemask
Running bat file - writing result into a file
etc..

<BOF> (bat file)
set Folder=\\server\folder
set FileMask=file*.txt
set LatestFile=
for /f "delims=" %%a in ('dir /b /o:d /a:-d "%Folder%\%Filemask%"') do
set LatestFile=%%a
if "%LatestFile%"=="" goto :missing
echo %LatestFile% >> c:\temp\FileCheckMonitor\filename.txt
goto :eof
:missing
echo mangler >> c:\temp\FileCheckMonitor\filename.txt
<EOF>

Running each new bat file and building up a textfile, listing newest
filenames from in each folder - if file exists in folder.
This is hundred times faster - at least - in my network.

I do not know vbs so deep but I suspect vbs to make an instance of
each file on the local computer - this is why it takes so long tine.
It does not not only read file properties on remote server.

Anyway - I found a solution which has reduced time dramatically..

If anyone knows a faster way - I'd be glad to hear -
Thanks everyone!


On 15 Mar., 00:35, "Al Dunbar" <aland...(a)hotmail.com> wrote:
> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>
> news:96e5404f-5054-407b-ae64-fc35be40a9be(a)z4g2000yqa.googlegroups.com...
>
> > Basicly I want to monitor severel forlders on severel servers.
> > In each folder I want to find the newest file - if any.
> > Filename and LastModified timestamp.
>
> > As network traffic slows down the proces getting information from
> > names like \\server1\data\something...
> > I want to make this faster
>
> > F.example a cal to a certain remote folder with over 800 files takes
> > severel minutes (4 to 5 minutes)
>
> It is a lot faster to do this kind of monitoring on a local hard drive than
> across a network. While it might be possible to tweak your code slightly, I
> think the bottleneck here is the network, and the processing that the remote
> system needs to do to accommodate the various accesses to its file system..
>
> Think about it. You are creating an object on your local system for each of
> hundreds of files that exist on a remote system. Where does this object
> reside, and where do all of its attributes reside? Even if it only fetches
> those attributes you request at the time the reference is made, there must
> still be somewhat more I/O going on than getting a simple directory listing
> for each file. Not that I am saying that that would be a better way to go....
>
> > On local server it takes a blink of an eye..
>
> Precisely. So why have you not followed Pegasus' advice and use psexec to
> get the remote servers to do the work for you, and then simply return the
> result?
>
> > I'm using this function... (takes 5 minutes on certain folders..too
> > much I think)
>
> It might be too much time for your purposes, however, it takes the time that
> it takes.
>
> /Al
>
>
>
> > (The timestamp array is to have full control og datetime format which
> > gave me some challange in danish interpretion of month day.. )
>
> > Sub CheckFolder(Fldr, mask, idx)
> >    NewestFileInFolder = ""
> >    Set oFolder =
> > CreateObject("scripting.filesystemobject").getfolder(Fldr)
> >    For Each aFile In oFolder.Files
> >        If NewestFileInFolder = "" Then
> >            Set NewestFileInFolder = aFile
> >        Else
> >            If RegExpTest(mask, aFile.Name) Then
> >                If NewestFileInFolder.DateLastModified <
> > aFile.DateLastModified Then
> >                    Set NewestFileInFolder = aFile
> >                    FileList(idx) = NewestFileInFolder.Name
> >                    TimeStampLastModifiedArray(idx, 1) =
> > Year(aFile.DateLastModified)
> >                    TimeStampLastModifiedArray(idx, 2) =
> > Month(aFile.DateLastModified)
> >                    TimeStampLastModifiedArray(idx, 3) =
> > Day(aFile.DateLastModified)
> >                    TimeStampLastModifiedArray(idx, 4) =
> > Hour(aFile.DateLastModified)
> >                    TimeStampLastModifiedArray(idx, 5) =
> > Minute(aFile.DateLastModified)
> >                    TimeStampLastModifiedArray(idx, 6) =
> > Second(aFile.DateLastModified)
>
> >                End If
> >            End If
> >        End If
> >    Next
> > End Sub
>
> > (This information tells me that some processes are runing as they
> > suppose to do.
> > some file have to be updated in certain intervals.
> > Files certain folders gives me kinda status from processes..)
>
> > On 12 Mar., 16:21, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
> >> I don't quite see what your two points have to do with each other:
> >> - Redirect the output from the "dir" command into a file
> >> - Select a specific output format.
>
> >> To me they look completely independent. What information do you actually
> >> reqjuire? Let's see an example!
>
> >> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>
> >>news:d3d1062f-436d-420f-abea-26d5c5fd99f3(a)o3g2000yqb.googlegroups.com....
>
> >> > Hi again
>
> >> > In order to speed up things I can see that it is faster to make a
> >> > redirection of a ls or dir command to a file.
> >> > Then from the file take out the last modified timestamp.
>
> >> > The thing is that dir gives some disk info.. and when adding the /b
> >> > option no diskinfo is comming up BUT the  time info is omitted.
>
> >> > So I need something in between.
>
> >> > On 12 Mar., 10:59, Leon <kim.zeth...(a)gmail.com> wrote:
> >> >> Hi Pegasus
>
> >> >> I'll for sure try it out!!
> >> >> Thanks!!!
> >> >> :-)
> >> >> Have a nice weekend
> >> >> Go helg
>
> >> >> On 12 Mar., 00:29, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
>
> >> >> > "Leon" <kim.zeth...(a)gmail.com> wrote in message
>
> >> >> >news:f9d98c33-d656-424b-9ce5-91da71945168(a)d27g2000yqf.googlegroups..com...
>
> >> >> > > Hi guys!
>
> >> >> > > Now I was able to hit..
> >> >> > > I'll try this out..
>
> >> >> > > Thanks..
>
> >> >> > > The thing is that I want to monitor sererel servers.. and want to
> >> >> > > run
> >> >> > > the script on a central pc.
> >> >> > > så running script remotely does not bring me closer - I think...
> >> >> > > Mayby I havent got the clu - I'l invest your suggeston.
>
> >> >> > > Thanks for answering! :-)
> >> >> > > Cheers
>
> >> >> > When you play with psexec.exe then you will see that you can invoke
> >> >> > it
> >> >> > from
> >> >> > your own machine so that it runs its task on any number of remote
> >> >> > machines.
> >> >> > If you do it correctly then you can get each of these tasks to
> >> >> > report
> >> >> > its
> >> >> > result on your own machine. The key is that you must play with it to
> >> >> > understand it. Om du lekar med psexec en stund så kan du snart se
> >> >> > hur
> >> >> > den
> >> >> > funkar.- Skjul tekst i anførselstegn -
>
> >> >> - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> >> - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -

From: Tom Lavedas on
On Mar 19, 9:38 am, Leon <kim.zeth...(a)gmail.com> wrote:
> Hi
>
> Yes maybe it just takes the time it takes.. hmm
> And why not do remote scripting..no.. I want a tool that can be
> maintained without processes on every remote server ..  :-)
>
> But using DOS command speeds this task up from several minutes to
> seconds
>
> looping through array with specified folders with VBS..

I don't think this approach (using console DIR command) needs to write
a batch procedure. I usually use a generalized function to run
console applications and collect the output. I've posted it many
times, generally under the function name of CmdPrompt. In this case,
it might be more useful to use a function specifically designed to
return the desired result for each search, something like this ...

Function Newest(sPath, sMask)
Dim sText, sCmdLine, stemp, ofs, oWS, s1stLines
set ofs = CreateObject("Scripting.FileSystemObject")
with CreateObject("Wscript.Shell")
stemp = .Environment("PROCESS")("TEMP") & "\" _
& ofs.GetTempName
sCmdLine = """%comspec%"" /c dir /o-d /a-d " _
& sPath & ".\" & sMask & " 1>> " _
& Chr(34) & sTemp & Chr(34) & " 2>nul "
s1stLine = Space(39) & "*** Error code: " _
& .Run(sCmdLine , 0, True) & " ***"
end with
if ofs.FileExists(sTemp) Then
with ofs.OpenTextFile(stemp)
if Not .AtEndofStream Then _
sText = Split(.ReadAll, vbNewline)(5)
end with
ofs.Deletefile sTemp
if len(sText) > 0 then
s1stLine = sText
else
s1stLine = Space(39) & "*** None found ***"
end if
End if
Newest = Array(Mid(s1stLine, 40), Trim(Left(s1stLine,20)))
End Function

The function returns a two element array. The element(0) is the
newest file's name and element(1) is its DateLastModified. If there
are no files matching the mask, the first element is "*** None found
***" and the second element is empty.

I don't know if this is faster or not, but I suspect it is simpler so
that future maintenance of the code should be easier.
_____________________
Tom Lavedas
From: Al Dunbar on


"Leon" <kim.zethsen(a)gmail.com> wrote in message
news:b8f77a3d-f474-4159-86f6-62e008895992(a)f8g2000yqn.googlegroups.com...
> Hi
>
> Yes mayne it just takes the time it takes.. hmm
> And why not do remote scripting..no.. I want a tool that can be
> maintained without processes on every remote server .. :-)

Have you actually tried psexec out? I have used it to run scripts remotely
on all of our workstations, and there was no need to manage or maintain
scripts, processes, or anything else on these systems - psexec did it all.

> But using DOS command speeds this task up from severel minutes to
> seconds
>
> looping through array with specified folders with VBS..
>
> Creating bat file by code
> Running bat file - writing result into a file
> Overwrite bat file with new folderspec and filemask
> Running bat file - writing result into a file
> etc..
>
> <BOF> (bat file)
> set Folder=\\server\folder
> set FileMask=file*.txt
> set LatestFile=
> for /f "delims=" %%a in ('dir /b /o:d /a:-d "%Folder%\%Filemask%"') do
> set LatestFile=%%a
> if "%LatestFile%"=="" goto :missing
> echo %LatestFile% >> c:\temp\FileCheckMonitor\filename.txt
> goto :eof
> :missing
> echo mangler >> c:\temp\FileCheckMonitor\filename.txt
> <EOF>
>
> Running each new bat file and building up a textfile, listing newest
> filenames from in each folder - if file exists in folder.
> This is hundred times faster - at least - in my network.

What is faster is that batch is simply doing a DIR operation across the
network - a reasonably light task. But, as Tom says in a later post, I don't
see why you need to create new versions of the batch file that does the
work. Just make it generic and pass it parameters when it is called.

Or, alternately, create a text file containing the various parameters it
needs to operate on, and call the batch once, and have it read through the
text file to determine what dir command to run.

I know this is not a batch ng, but, if it were, surely someone would suggest
a few minor changes, like:

enclosing set commands in parenthesis to avoid inadvertent trailing
whitespace, i.e.:

(set latest=)

structured programming, more direct tests, and echo/ instead of echo:

if defined LatestFile (
echo/%LatestFile% >> c:\temp\FileCheckMonitor\filename.txt
) else (
echo/mangler >> c:\temp\FileCheckMonitor\filename.txt
)

> I do not know vbs so deep but I suspect vbs to make an instance of
> each file on the local computer - this is why it takes so long tine.

An instance of a file would be a copy, and no, it does not do that. It
creates an object on the local computer that represents various properties
of the remote file.

> It does not not only read file properties on remote server.
>
> Anyway - I found a solution which has reduced time dramatically..

And that was precisely what you needed. Great.

> If anyone knows a faster way - I'd be glad to hear -
> Thanks everyone!

If your vbscript winds up creating a different batch file for each DIR
command that needs to be run, you can probably make that part simple and
more efficient. But I doubt it would speed things up significantly, as I
think the bottleneck is still the network.

/Al


>
>
> On 15 Mar., 00:35, "Al Dunbar" <aland...(a)hotmail.com> wrote:
>> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>>
>> news:96e5404f-5054-407b-ae64-fc35be40a9be(a)z4g2000yqa.googlegroups.com...
>>
>> > Basicly I want to monitor severel forlders on severel servers.
>> > In each folder I want to find the newest file - if any.
>> > Filename and LastModified timestamp.
>>
>> > As network traffic slows down the proces getting information from
>> > names like \\server1\data\something...
>> > I want to make this faster
>>
>> > F.example a cal to a certain remote folder with over 800 files takes
>> > severel minutes (4 to 5 minutes)
>>
>> It is a lot faster to do this kind of monitoring on a local hard drive
>> than
>> across a network. While it might be possible to tweak your code slightly,
>> I
>> think the bottleneck here is the network, and the processing that the
>> remote
>> system needs to do to accommodate the various accesses to its file
>> system.
>>
>> Think about it. You are creating an object on your local system for each
>> of
>> hundreds of files that exist on a remote system. Where does this object
>> reside, and where do all of its attributes reside? Even if it only
>> fetches
>> those attributes you request at the time the reference is made, there
>> must
>> still be somewhat more I/O going on than getting a simple directory
>> listing
>> for each file. Not that I am saying that that would be a better way to
>> go...
>>
>> > On local server it takes a blink of an eye..
>>
>> Precisely. So why have you not followed Pegasus' advice and use psexec to
>> get the remote servers to do the work for you, and then simply return the
>> result?
>>
>> > I'm using this function... (takes 5 minutes on certain folders..too
>> > much I think)
>>
>> It might be too much time for your purposes, however, it takes the time
>> that
>> it takes.
>>
>> /Al
>>
>>
>>
>> > (The timestamp array is to have full control og datetime format which
>> > gave me some challange in danish interpretion of month day.. )
>>
>> > Sub CheckFolder(Fldr, mask, idx)
>> > NewestFileInFolder = ""
>> > Set oFolder =
>> > CreateObject("scripting.filesystemobject").getfolder(Fldr)
>> > For Each aFile In oFolder.Files
>> > If NewestFileInFolder = "" Then
>> > Set NewestFileInFolder = aFile
>> > Else
>> > If RegExpTest(mask, aFile.Name) Then
>> > If NewestFileInFolder.DateLastModified <
>> > aFile.DateLastModified Then
>> > Set NewestFileInFolder = aFile
>> > FileList(idx) = NewestFileInFolder.Name
>> > TimeStampLastModifiedArray(idx, 1) =
>> > Year(aFile.DateLastModified)
>> > TimeStampLastModifiedArray(idx, 2) =
>> > Month(aFile.DateLastModified)
>> > TimeStampLastModifiedArray(idx, 3) =
>> > Day(aFile.DateLastModified)
>> > TimeStampLastModifiedArray(idx, 4) =
>> > Hour(aFile.DateLastModified)
>> > TimeStampLastModifiedArray(idx, 5) =
>> > Minute(aFile.DateLastModified)
>> > TimeStampLastModifiedArray(idx, 6) =
>> > Second(aFile.DateLastModified)
>>
>> > End If
>> > End If
>> > End If
>> > Next
>> > End Sub
>>
>> > (This information tells me that some processes are runing as they
>> > suppose to do.
>> > some file have to be updated in certain intervals.
>> > Files certain folders gives me kinda status from processes..)
>>
>> > On 12 Mar., 16:21, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
>> >> I don't quite see what your two points have to do with each other:
>> >> - Redirect the output from the "dir" command into a file
>> >> - Select a specific output format.
>>
>> >> To me they look completely independent. What information do you
>> >> actually
>> >> reqjuire? Let's see an example!
>>
>> >> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>>
>> >>news:d3d1062f-436d-420f-abea-26d5c5fd99f3(a)o3g2000yqb.googlegroups.com...
>>
>> >> > Hi again
>>
>> >> > In order to speed up things I can see that it is faster to make a
>> >> > redirection of a ls or dir command to a file.
>> >> > Then from the file take out the last modified timestamp.
>>
>> >> > The thing is that dir gives some disk info.. and when adding the /b
>> >> > option no diskinfo is comming up BUT the time info is omitted.
>>
>> >> > So I need something in between.
>>
>> >> > On 12 Mar., 10:59, Leon <kim.zeth...(a)gmail.com> wrote:
>> >> >> Hi Pegasus
>>
>> >> >> I'll for sure try it out!!
>> >> >> Thanks!!!
>> >> >> :-)
>> >> >> Have a nice weekend
>> >> >> Go helg
>>
>> >> >> On 12 Mar., 00:29, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
>>
>> >> >> > "Leon" <kim.zeth...(a)gmail.com> wrote in message
>>
>> >> >> >news:f9d98c33-d656-424b-9ce5-91da71945168(a)d27g2000yqf.googlegroups.com...
>>
>> >> >> > > Hi guys!
>>
>> >> >> > > Now I was able to hit..
>> >> >> > > I'll try this out..
>>
>> >> >> > > Thanks..
>>
>> >> >> > > The thing is that I want to monitor sererel servers.. and want
>> >> >> > > to
>> >> >> > > run
>> >> >> > > the script on a central pc.
>> >> >> > > s� running script remotely does not bring me closer - I think..
>> >> >> > > Mayby I havent got the clu - I'l invest your suggeston.
>>
>> >> >> > > Thanks for answering! :-)
>> >> >> > > Cheers
>>
>> >> >> > When you play with psexec.exe then you will see that you can
>> >> >> > invoke
>> >> >> > it
>> >> >> > from
>> >> >> > your own machine so that it runs its task on any number of remote
>> >> >> > machines.
>> >> >> > If you do it correctly then you can get each of these tasks to
>> >> >> > report
>> >> >> > its
>> >> >> > result on your own machine. The key is that you must play with it
>> >> >> > to
>> >> >> > understand it. Om du lekar med psexec en stund s� kan du snart se
>> >> >> > hur
>> >> >> > den
>> >> >> > funkar.- Skjul tekst i anf�rselstegn -
>>
>> >> >> - Vis tekst i anf�rselstegn -- Skjul tekst i anf�rselstegn -
>>
>> >> - Vis tekst i anf�rselstegn -- Skjul tekst i anf�rselstegn -
>>
>> - Vis tekst i anf�rselstegn -
>
From: Leon on
Hi

Thanks for batchtips - already made one batch instead of one for
each...

cheers

On 20 Mar., 05:33, "Al Dunbar" <aland...(a)hotmail.com> wrote:
> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>
> news:b8f77a3d-f474-4159-86f6-62e008895992(a)f8g2000yqn.googlegroups.com...
>
> > Hi
>
> > Yes mayne it just takes the time it takes.. hmm
> > And why not do remote scripting..no.. I want a tool that can be
> > maintained without processes on every remote server ..  :-)
>
> Have you actually tried psexec out? I have used it to run scripts remotely
> on all of our workstations, and there was no need to manage or maintain
> scripts, processes, or anything else on these systems - psexec did it all..
>
>
>
>
>
> > But using DOS command speeds this task up from severel minutes to
> > seconds
>
> > looping through array with specified folders with VBS..
>
> >   Creating bat file by code
> >   Running bat file - writing result into a file
> >   Overwrite bat file with new folderspec and filemask
> >   Running bat file - writing result into a file
> >   etc..
>
> > <BOF> (bat file)
> > set Folder=\\server\folder
> > set FileMask=file*.txt
> > set LatestFile=
> > for /f "delims=" %%a in ('dir /b /o:d /a:-d "%Folder%\%Filemask%"') do
> > set LatestFile=%%a
> > if "%LatestFile%"=="" goto :missing
> > echo %LatestFile% >> c:\temp\FileCheckMonitor\filename.txt
> > goto :eof
> > :missing
> > echo mangler >> c:\temp\FileCheckMonitor\filename.txt
> > <EOF>
>
> > Running each new bat file and building up a textfile, listing newest
> > filenames from in each folder - if file exists in folder.
> > This is hundred times faster - at least - in my network.
>
> What is faster is that batch is simply doing a DIR operation across the
> network - a reasonably light task. But, as Tom says in a later post, I don't
> see why you need to create new versions of the batch file that does the
> work. Just make it generic and pass it parameters when it is called.
>
> Or, alternately, create a text file containing the various parameters it
> needs to operate on, and call the batch once, and have it read through the
> text file to determine what dir command to run.
>
> I know this is not a batch ng, but, if it were, surely someone would suggest
> a few minor changes, like:
>
> enclosing set commands in parenthesis to avoid inadvertent trailing
> whitespace, i.e.:
>
>     (set latest=)
>
> structured programming, more direct tests, and echo/ instead of echo:
>
>     if defined LatestFile (
>         echo/%LatestFile% >> c:\temp\FileCheckMonitor\filename.txt
>     ) else (
>         echo/mangler >> c:\temp\FileCheckMonitor\filename.txt
>     )
>
> > I do not know vbs so deep but I suspect vbs to make an instance of
> > each file on the local computer - this is why it takes so long tine.
>
> An instance of a file would be a copy, and no, it does not do that. It
> creates an object on the local computer that represents various properties
> of the remote file.
>
> > It does not not only read file properties on remote server.
>
> > Anyway - I found a solution which has reduced time dramatically..
>
> And that was precisely what you needed. Great.
>
> > If anyone knows a faster way - I'd be glad to hear -
> > Thanks everyone!
>
> If your vbscript winds up creating a different batch file for each DIR
> command that needs to be run, you can probably make that part simple and
> more efficient. But I doubt it would speed things up significantly, as I
> think the bottleneck is still the network.
>
> /Al
>
>
>
>
>
> > On 15 Mar., 00:35, "Al Dunbar" <aland...(a)hotmail.com> wrote:
> >> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>
> >>news:96e5404f-5054-407b-ae64-fc35be40a9be(a)z4g2000yqa.googlegroups.com....
>
> >> > Basicly I want to monitor severel forlders on severel servers.
> >> > In each folder I want to find the newest file - if any.
> >> > Filename and LastModified timestamp.
>
> >> > As network traffic slows down the proces getting information from
> >> > names like \\server1\data\something...
> >> > I want to make this faster
>
> >> > F.example a cal to a certain remote folder with over 800 files takes
> >> > severel minutes (4 to 5 minutes)
>
> >> It is a lot faster to do this kind of monitoring on a local hard drive
> >> than
> >> across a network. While it might be possible to tweak your code slightly,
> >> I
> >> think the bottleneck here is the network, and the processing that the
> >> remote
> >> system needs to do to accommodate the various accesses to its file
> >> system.
>
> >> Think about it. You are creating an object on your local system for each
> >> of
> >> hundreds of files that exist on a remote system. Where does this object
> >> reside, and where do all of its attributes reside? Even if it only
> >> fetches
> >> those attributes you request at the time the reference is made, there
> >> must
> >> still be somewhat more I/O going on than getting a simple directory
> >> listing
> >> for each file. Not that I am saying that that would be a better way to
> >> go...
>
> >> > On local server it takes a blink of an eye..
>
> >> Precisely. So why have you not followed Pegasus' advice and use psexec to
> >> get the remote servers to do the work for you, and then simply return the
> >> result?
>
> >> > I'm using this function... (takes 5 minutes on certain folders..too
> >> > much I think)
>
> >> It might be too much time for your purposes, however, it takes the time
> >> that
> >> it takes.
>
> >> /Al
>
> >> > (The timestamp array is to have full control og datetime format which
> >> > gave me some challange in danish interpretion of month day.. )
>
> >> > Sub CheckFolder(Fldr, mask, idx)
> >> >    NewestFileInFolder = ""
> >> >    Set oFolder =
> >> > CreateObject("scripting.filesystemobject").getfolder(Fldr)
> >> >    For Each aFile In oFolder.Files
> >> >        If NewestFileInFolder = "" Then
> >> >            Set NewestFileInFolder = aFile
> >> >        Else
> >> >            If RegExpTest(mask, aFile.Name) Then
> >> >                If NewestFileInFolder.DateLastModified <
> >> > aFile.DateLastModified Then
> >> >                    Set NewestFileInFolder = aFile
> >> >                    FileList(idx) = NewestFileInFolder.Name
> >> >                    TimeStampLastModifiedArray(idx, 1) =
> >> > Year(aFile.DateLastModified)
> >> >                    TimeStampLastModifiedArray(idx, 2) =
> >> > Month(aFile.DateLastModified)
> >> >                    TimeStampLastModifiedArray(idx, 3) =
> >> > Day(aFile.DateLastModified)
> >> >                    TimeStampLastModifiedArray(idx, 4) =
> >> > Hour(aFile.DateLastModified)
> >> >                    TimeStampLastModifiedArray(idx, 5) =
> >> > Minute(aFile.DateLastModified)
> >> >                    TimeStampLastModifiedArray(idx, 6) =
> >> > Second(aFile.DateLastModified)
>
> >> >                End If
> >> >            End If
> >> >        End If
> >> >    Next
> >> > End Sub
>
> >> > (This information tells me that some processes are runing as they
> >> > suppose to do.
> >> > some file have to be updated in certain intervals.
> >> > Files certain folders gives me kinda status from processes..)
>
> >> > On 12 Mar., 16:21, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
> >> >> I don't quite see what your two points have to do with each other:
> >> >> - Redirect the output from the "dir" command into a file
> >> >> - Select a specific output format.
>
> >> >> To me they look completely independent. What information do you
> >> >> actually
> >> >> reqjuire? Let's see an example!
>
> >> >> "Leon" <kim.zeth...(a)gmail.com> wrote in message
>
> >> >>news:d3d1062f-436d-420f-abea-26d5c5fd99f3(a)o3g2000yqb.googlegroups.com...
>
> >> >> > Hi again
>
> >> >> > In order to speed up things I can see that it is faster to make a
> >> >> > redirection of a ls or dir command to a file.
> >> >> > Then from the file take out the last modified timestamp.
>
> >> >> > The thing is that dir gives some disk info.. and when adding the /b
> >> >> > option no diskinfo is comming up BUT the  time info is omitted.
>
> >> >> > So I need something in between.
>
> >> >> > On 12 Mar., 10:59, Leon <kim.zeth...(a)gmail.com> wrote:
> >> >> >> Hi Pegasus
>
> >> >> >> I'll for sure try it out!!
> >> >> >> Thanks!!!
> >> >> >> :-)
> >> >> >> Have a nice weekend
> >> >> >> Go helg
>
> >> >> >> On 12 Mar., 00:29, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
>
> >> >> >> > "Leon" <kim.zeth...(a)gmail.com> wrote in message
>
> >> >> >> >news:f9d98c33-d656-424b-9ce5-91da71945168(a)d27g2000yqf.googlegroups.com...
>
> >> >> >> > > Hi guys!
>
> >> >> >> > > Now I was able to hit..
> >> >> >> > > I'll try this out..
>
> >> >> >> > > Thanks..
>
> >> >> >> > > The thing is that I want to monitor sererel servers.. and want
> >> >> >> > > to
> >> >> >> > > run
> >> >> >> > > the script on a central pc.
> >> >> >> > > så running script remotely does not bring me closer - I think..
> >> >> >> > > Mayby I havent got the clu - I'l invest your suggeston.
>
> >> >> >> > > Thanks for answering! :-)
> >> >> >> > > Cheers
>
> >> >> >> > When you play with psexec.exe then you will see that you can
> >> >> >> > invoke
> >> >> >> > it
> >> >> >> > from
> >> >> >> > your own machine so that it runs its task on any number of remote
> >> >> >> > machines.
> >> >> >> > If you do it correctly then you can get each of these tasks to
> >> >> >> > report
> >> >> >> > its
> >> >> >> > result on your own machine. The key is that you must play with it
> >> >> >> > to
> >> >> >> > understand it. Om du lekar med psexec en stund så kan du snart se
> >> >> >> > hur
> >> >> >> > den
> >> >> >> > funkar.- Skjul tekst i anførselstegn -
>
> >> >> >> - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> >> >> - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> >> - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -