Sign-in / Sign-up
Your question

Making a Script File for Scheduler

Tags:
  • Internet Explorer
  • Outlook Express
  • Microsoft
  • Windows
Last response: in Windows 2000/NT
Anonymous
July 28, 2005 9:15:09 PM

Archived from groups: microsoft.public.win2000.general (More info?)

Hi;

I made a script file that I run every hour with scheduler. What it does is
start up Internet Explorer and sends it to a certain web address. The
problem is that I end up with many open windows from IE when I've been away
for a while.

Does anyone know a better way of doing this that would not result in windows
being left open? Currently the script looks like this;

"C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://URL"

For some reason I cannot reply to this group with Outlook Express - I can
only create messages :-) I suspect there is an issue with some of the
updates Microsoft has released recently (it only does this after certain
updates are installed.)

Anyway, if anyone knows a better way to 'skin' this cat I'd like to hear
it.. and I guess I can always use Microsoft's HTML interface for this group
to reply;

Best & Thanks;
Marvin

More about : making script file scheduler

Anonymous
August 1, 2005 1:18:02 AM

Archived from groups: microsoft.public.win2000.general (More info?)

Marvin Miller wrote:

> I made a script file that I run every hour with scheduler. What it does is
> start up Internet Explorer and sends it to a certain web address. The
> problem is that I end up with many open windows from IE when I've been away
> for a while.
>
> Does anyone know a better way of doing this that would not result in windows
> being left open? Currently the script looks like this;
>
> "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://URL"
>
> (snip)
Hi,

If you use a VBScript (.vbs file) instead of a batch file in your
scheduled task, there are some options. Try the script below and see
how it works for you.

In task configuration, set it to start the script like this:

wscript.exe "path to your .vbs file"
e.g.
wscript.exe "C:\Scripts\LaunchURLFromTask.vbs"


In the script below, adjust the URL in the sUrlToOpen variable to the
URL you want to open.


'--------------------8<----------------------

' URL to open if not already open (a Left part string test will be done)
sUrlToOpen = "http://www.microsoft.com"

Set oShApp = CreateObject("Shell.Application")
Set oShell = CreateObject("Wscript.Shell")

bolUrlAlreadyOpen = False ' init value
On Error Resume Next
For Each oWin In oShApp.Windows
bolIE = CBool(InStr(LCase(TypeName(oWin.Document)),"htmldocument"))
If Err.Number = 0 Then
If bolIE Then
sURL = "" ' init value
sURL = oWin.locationURL
If Trim(sUrl) <> "" Then
If LCase(Left(sUrl, Len(sUrlToOpen))) = LCase(sUrlToOpen) Then
bolUrlAlreadyOpen = True
End If
End If
End If
End If
Err.Clear
If bolUrlAlreadyOpen Then Exit For
Next
On Error Goto 0

If Not bolUrlAlreadyOpen Then
' Full path to iexplore.exe is not necessary when using the Run method
sCmd = "iexplore.exe " & sUrlToOpen
oShell.Run sCmd, 1, False
End If

'--------------------8<----------------------


WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp



--
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.m...
Anonymous
August 1, 2005 1:18:03 AM

Archived from groups: microsoft.public.win2000.general (More info?)

Hi Torgeir;

Thanks very much for taking the time to reply!
I'm not much of a programmer but I was able to get the script up and running.
When I called it from task sheduler it opened IE, went to the proper web
page but did not close the browser window. So it was close, but no cigar :-)

Any ideas on why it didn't close the window?

Thanks again;
Marvin Miller



"Torgeir Bakken (MVP)" wrote:

> Marvin Miller wrote:
>
> > I made a script file that I run every hour with scheduler. What it does is
> > start up Internet Explorer and sends it to a certain web address. The
> > problem is that I end up with many open windows from IE when I've been away
> > for a while.
> >
> > Does anyone know a better way of doing this that would not result in windows
> > being left open? Currently the script looks like this;
> >
> > "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://URL"
> >
> > (snip)
> Hi,
>
> If you use a VBScript (.vbs file) instead of a batch file in your
> scheduled task, there are some options. Try the script below and see
> how it works for you.
>
> In task configuration, set it to start the script like this:
>
> wscript.exe "path to your .vbs file"
> e.g.
> wscript.exe "C:\Scripts\LaunchURLFromTask.vbs"
>
>
> In the script below, adjust the URL in the sUrlToOpen variable to the
> URL you want to open.
>
>
> '--------------------8<----------------------
>
> ' URL to open if not already open (a Left part string test will be done)
> sUrlToOpen = "http://www.microsoft.com"
>
> Set oShApp = CreateObject("Shell.Application")
> Set oShell = CreateObject("Wscript.Shell")
>
> bolUrlAlreadyOpen = False ' init value
> On Error Resume Next
> For Each oWin In oShApp.Windows
> bolIE = CBool(InStr(LCase(TypeName(oWin.Document)),"htmldocument"))
> If Err.Number = 0 Then
> If bolIE Then
> sURL = "" ' init value
> sURL = oWin.locationURL
> If Trim(sUrl) <> "" Then
> If LCase(Left(sUrl, Len(sUrlToOpen))) = LCase(sUrlToOpen) Then
> bolUrlAlreadyOpen = True
> End If
> End If
> End If
> End If
> Err.Clear
> If bolUrlAlreadyOpen Then Exit For
> Next
> On Error Goto 0
>
> If Not bolUrlAlreadyOpen Then
> ' Full path to iexplore.exe is not necessary when using the Run method
> sCmd = "iexplore.exe " & sUrlToOpen
> oShell.Run sCmd, 1, False
> End If
>
> '--------------------8<----------------------
>
>
> WSH 5.6 documentation (local help file) can be downloaded
> from here if you haven't got it already:
> http://msdn.microsoft.com/downloads/list/webdev.asp
>
>
>
> --
> 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.m...
>
Anonymous
August 1, 2005 3:44:45 PM

Archived from groups: microsoft.public.win2000.general (More info?)

Marvin Miller wrote:

> Hi Torgeir;
>
> Thanks very much for taking the time to reply!
> I'm not much of a programmer but I was able to get the script up and running.
> When I called it from task sheduler it opened IE, went to the proper web
> page but did not close the browser window. So it was close, but no cigar :-)
>
> Any ideas on why it didn't close the window?
>
Hi,

I'm not completely with you here.

The script I posted, is designed so it opens the browser window, and
next time the script runs, if it detects that the "old" browser
windows still is open, it will not start a new browser session (so
the old session will continue to run "alone").

Some questions for you:

1)
Why do you want to open a browser window and then just close it
again (from the script)?

2)
Or did you really mean that if the old window exists when the script
runs again. you want to close the old window and open up a new
instance?

3)
Previously, with your old solution, did it close by itself?

4)
The old solution, was that a batch file, or did you just add this
line directly into the scheduled task:
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://URL"



--
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.m...