hi

i have the following script which takes a server list, splits it up, maps a
drive to each server and checks the date last modified of a particular file

seems ok except for one strange issue

server1's file has a dlm of 11/04/05
server2's file has a dlm of 28/04/05

when i run the script it reports back the other way round. i.e. server1 as
28/04/05 and server2 as 11/04/05

the map.cmd command removes the current L: mapping and maps to servlist(x).
this is OK as i have generated an audit file from this and it maps the
correct way around (i.e. server1 first followed by server2)

any ideas?

cheers

option explicit
Dim WshShell, fso, file, lmdate, servfile, servlist(30), sl, x, y, server
set WshShell = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
set file = fso.getfile("L:\myfile.vbs")
set servfile = fso.opentextfile("serverlist.txt",1)

x = 0

Do While Not servfile.AtEndOfStream
sl = servfile.readline
servlist(x) = sl
x = x + 1
loop

y = x
x = 0

for x = 0 to eval(y-1)

wshshell.run "map.cmd "&servlist(x),true
lmdate = file.DateLastModified
lmdate = left(lmdate,10)
if lmdate = "11/04/2005" then
msgbox servlist(x)&" "&lmdate
else
msgbox servlist(x)&" wrong date"
end if

next

RE: script out of time? by billytf

billytf
Wed Apr 27 20:58:04 CDT 2005

seems it is a timing issue. if i put a sleep method for a few seconds after
calling map.cmd its all ok

still, any ideas as to why this happens would be good

also, why doesnt the 'true' boolean value on the run method work? surely it
should be waiting for the external command to finish before processing the
rest of the script?

"billytf" wrote:

> hi
>
> i have the following script which takes a server list, splits it up, maps a
> drive to each server and checks the date last modified of a particular file
>
> seems ok except for one strange issue
>
> server1's file has a dlm of 11/04/05
> server2's file has a dlm of 28/04/05
>
> when i run the script it reports back the other way round. i.e. server1 as
> 28/04/05 and server2 as 11/04/05
>
> the map.cmd command removes the current L: mapping and maps to servlist(x).
> this is OK as i have generated an audit file from this and it maps the
> correct way around (i.e. server1 first followed by server2)
>
> any ideas?
>
> cheers
>
> option explicit
> Dim WshShell, fso, file, lmdate, servfile, servlist(30), sl, x, y, server
> set WshShell = createobject("wscript.shell")
> set fso = createobject("scripting.filesystemobject")
> set file = fso.getfile("L:\myfile.vbs")
> set servfile = fso.opentextfile("serverlist.txt",1)
>
> x = 0
>
> Do While Not servfile.AtEndOfStream
> sl = servfile.readline
> servlist(x) = sl
> x = x + 1
> loop
>
> y = x
> x = 0
>
> for x = 0 to eval(y-1)
>
> wshshell.run "map.cmd "&servlist(x),true
> lmdate = file.DateLastModified
> lmdate = left(lmdate,10)
> if lmdate = "11/04/2005" then
> msgbox servlist(x)&" "&lmdate
> else
> msgbox servlist(x)&" wrong date"
> end if
>
> next
>

RE: script out of time? by billytf

billytf
Wed Apr 27 21:22:02 CDT 2005

ok. worked out the issue is definately with timing. i was running the script
more than once, meaning L: was mapped to server2 at the start of the scripr
from the previous execution

so, the question become...

why doesnt the script wait for

wshshell.run "map.cmd "&servlist(x),true

to complete before continuing?

ps. i have also moved 'set file = fso.getfile("L:\myfile.vbs")' after the
map statement

"billytf" wrote:

> hi
>
> i have the following script which takes a server list, splits it up, maps a
> drive to each server and checks the date last modified of a particular file
>
> seems ok except for one strange issue
>
> server1's file has a dlm of 11/04/05
> server2's file has a dlm of 28/04/05
>
> when i run the script it reports back the other way round. i.e. server1 as
> 28/04/05 and server2 as 11/04/05
>
> the map.cmd command removes the current L: mapping and maps to servlist(x).
> this is OK as i have generated an audit file from this and it maps the
> correct way around (i.e. server1 first followed by server2)
>
> any ideas?
>
> cheers
>
> option explicit
> Dim WshShell, fso, file, lmdate, servfile, servlist(30), sl, x, y, server
> set WshShell = createobject("wscript.shell")
> set fso = createobject("scripting.filesystemobject")
> set file = fso.getfile("L:\myfile.vbs")
> set servfile = fso.opentextfile("serverlist.txt",1)
>
> x = 0
>
> Do While Not servfile.AtEndOfStream
> sl = servfile.readline
> servlist(x) = sl
> x = x + 1
> loop
>
> y = x
> x = 0
>
> for x = 0 to eval(y-1)
>
> wshshell.run "map.cmd "&servlist(x),true
> lmdate = file.DateLastModified
> lmdate = left(lmdate,10)
> if lmdate = "11/04/2005" then
> msgbox servlist(x)&" "&lmdate
> else
> msgbox servlist(x)&" wrong date"
> end if
>
> next
>

Re: script out of time? by Michael

Michael
Wed Apr 27 22:23:31 CDT 2005

billytf wrote:
> ok. worked out the issue is definately with timing. i was running the
> script more than once, meaning L: was mapped to server2 at the start
> of the scripr from the previous execution
>
> so, the question become...
>
> why doesnt the script wait for
>
> wshshell.run "map.cmd "&servlist(x),true
>


intWindowStyle = 0 'hidden
bWaitOnReturn = true 'wait

wshshell.run "map.cmd "&servlist(x), intWindowStyle ,bWaitOnReturn



> to complete before continuing?
>
> ps. i have also moved 'set file = fso.getfile("L:\myfile.vbs")' after
> the map statement
>
> "billytf" wrote:
>
>> hi
>>
>> i have the following script which takes a server list, splits it up,
>> maps a drive to each server and checks the date last modified of a
>> particular file
>>
>> seems ok except for one strange issue
>>
>> server1's file has a dlm of 11/04/05
>> server2's file has a dlm of 28/04/05
>>
>> when i run the script it reports back the other way round. i.e.
>> server1 as 28/04/05 and server2 as 11/04/05
>>
>> the map.cmd command removes the current L: mapping and maps to
>> servlist(x). this is OK as i have generated an audit file from this
>> and it maps the correct way around (i.e. server1 first followed by
>> server2)
>>
>> any ideas?
>>
>> cheers
>>
>> option explicit
>> Dim WshShell, fso, file, lmdate, servfile, servlist(30), sl, x, y,
>> server set WshShell = createobject("wscript.shell")
>> set fso = createobject("scripting.filesystemobject")
>> set file = fso.getfile("L:\myfile.vbs")
>> set servfile = fso.opentextfile("serverlist.txt",1)
>>
>> x = 0
>>
>> Do While Not servfile.AtEndOfStream
>> sl = servfile.readline
>> servlist(x) = sl
>> x = x + 1
>> loop
>>
>> y = x
>> x = 0
>>
>> for x = 0 to eval(y-1)
>>
>> wshshell.run "map.cmd "&servlist(x),true
>> lmdate = file.DateLastModified
>> lmdate = left(lmdate,10)
>> if lmdate = "11/04/2005" then
>> msgbox servlist(x)&" "&lmdate
>> else
>> msgbox servlist(x)&" wrong date"
>> end if
>>
>> next

--
Michael Harris
Microsoft MVP Scripting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Please ask follow-up questions via the original newsgroup thread.




Re: script out of time? by billytf

billytf
Wed Apr 27 23:22:02 CDT 2005

thanks michael

so you need to specify both the 'window style' AND the 'wait on return'
values just to use 'wait on return'. doesn't mention anything in the
documentation about that

good to know

cheers

"Michael Harris (MVP)" wrote:

> billytf wrote:
> > ok. worked out the issue is definately with timing. i was running the
> > script more than once, meaning L: was mapped to server2 at the start
> > of the scripr from the previous execution
> >
> > so, the question become...
> >
> > why doesnt the script wait for
> >
> > wshshell.run "map.cmd "&servlist(x),true
> >
>
>
> intWindowStyle = 0 'hidden
> bWaitOnReturn = true 'wait
>
> wshshell.run "map.cmd "&servlist(x), intWindowStyle ,bWaitOnReturn
>
>
>
> > to complete before continuing?
> >
> > ps. i have also moved 'set file = fso.getfile("L:\myfile.vbs")' after
> > the map statement
> >
> > "billytf" wrote:
> >
> >> hi
> >>
> >> i have the following script which takes a server list, splits it up,
> >> maps a drive to each server and checks the date last modified of a
> >> particular file
> >>
> >> seems ok except for one strange issue
> >>
> >> server1's file has a dlm of 11/04/05
> >> server2's file has a dlm of 28/04/05
> >>
> >> when i run the script it reports back the other way round. i.e.
> >> server1 as 28/04/05 and server2 as 11/04/05
> >>
> >> the map.cmd command removes the current L: mapping and maps to
> >> servlist(x). this is OK as i have generated an audit file from this
> >> and it maps the correct way around (i.e. server1 first followed by
> >> server2)
> >>
> >> any ideas?
> >>
> >> cheers
> >>
> >> option explicit
> >> Dim WshShell, fso, file, lmdate, servfile, servlist(30), sl, x, y,
> >> server set WshShell = createobject("wscript.shell")
> >> set fso = createobject("scripting.filesystemobject")
> >> set file = fso.getfile("L:\myfile.vbs")
> >> set servfile = fso.opentextfile("serverlist.txt",1)
> >>
> >> x = 0
> >>
> >> Do While Not servfile.AtEndOfStream
> >> sl = servfile.readline
> >> servlist(x) = sl
> >> x = x + 1
> >> loop
> >>
> >> y = x
> >> x = 0
> >>
> >> for x = 0 to eval(y-1)
> >>
> >> wshshell.run "map.cmd "&servlist(x),true
> >> lmdate = file.DateLastModified
> >> lmdate = left(lmdate,10)
> >> if lmdate = "11/04/2005" then
> >> msgbox servlist(x)&" "&lmdate
> >> else
> >> msgbox servlist(x)&" wrong date"
> >> end if
> >>
> >> next
>
> --
> Michael Harris
> Microsoft MVP Scripting
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Please ask follow-up questions via the original newsgroup thread.
>
>
>
>

Re: script out of time? by McKirahan

McKirahan
Thu Apr 28 05:05:53 CDT 2005

"billytf" <billytf@discussions.microsoft.com> wrote in message
news:0658E3E8-6BF9-43FA-B4AD-501E73F2669D@microsoft.com...
> thanks michael
>
> so you need to specify both the 'window style' AND the 'wait on return'
> values just to use 'wait on return'. doesn't mention anything in the
> documentation about that
>
> good to know
>
> cheers

Actually, it does.

Brackets "[]" indicate "optional"; no comma is in brackets.

From the WSH5.6 docs:

Run Method

Runs a program in a new process.

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])

Arguments

object
WshShell object.

strCommand
String value indicating the command line you want to run. You must
include any parameters you want to pass to the executable file.

intWindowStyle
Optional. Integer value indicating the appearance of the program's
window. Note that not all programs make use of this information.

bWaitOnReturn
Optional. Boolean value indicating whether the script should wait for
the program to finish executing before continuing to the next statement in
your script. If set to true, script execution halts until the program
finishes, and Run returns any error code returned by the program. If set to
false (the default), the Run method returns immediately after starting the
program, automatically returning 0 (not to be interpreted as an error code).



Re: script out of time? by Torgeir

Torgeir
Thu Apr 28 07:34:50 CDT 2005

billytf wrote:

> thanks michael
>
> so you need to specify both the 'window style' AND the 'wait on return'
> values just to use 'wait on return'. doesn't mention anything in the
> documentation about that
>
> good to know
Hi,

If you look at the documentation, 'wait on return' is the *3rd*
parameter to the Run method, and you don't need to specify the
'window style' parameter, but you need to place the 'wait on
return' as the 3rd parameter anyway.

This will work (note the two commas):

Set wshshell = CreateObject("WScript.Shell")
wshshell.run "notepad.exe",, True
MsgBox "Finished"


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx