Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WSH script not stopping when run with Windows XP Scheduled Tasks

9 views
Skip to first unread message

Michael Harris (MVP)

unread,
Oct 1, 2003, 4:27:58 PM10/1/03
to
Cheech Chong wrote:
> The script is run every 30 minutes from a Windows XP Scheduled Tasks
> job, but it doesn't seem to stop properly 100% of the time. I have
> set the Scheduled Tasks to stop the script after 10 minutes, but it
> won't start on its next schedule if it got stuck before.
>
> I've checked the Scheduled Tasks --> View Log to find a Start entry
> for the task, but no stop entry.
>
> Any ideas on how I could get the script to run more reliably?
> Currently the command line in Scheduled Tasks is:
> C:\get-ip.vbs


The problem is likely that your script is throwing an unhandled error. With
WScript.exe as the default host, you may not see the WSH error dialog box
when the script does not execute in the context of the visible desktop.


> I will be trying this command line shortly (after reading some
> previous newsgroup posts about cscript and wscript):
> C:\WINDOWS\system32\cscript.exe C:\get-ip.vbs //B //T:180
>


I would do

%comspec% /c cscript.exe C:\get-ip.vbs //B > c:\get-ip.output.txt


That way any error message written to standard output won't be lost...

> Below is the entire IP script


Here's a simpler way to get your own IP address by pinging your own machine
name...

wscript.echo myipaddress

function MyIPAddress()

MyIPAddress = ""

set net = createobject("wscript.network")
set shell = createobject("wscript.shell")
set re = new regexp
re.pattern = "\[(.+)?\]"
with shell.exec("ping -n 1 -w 500 " & net.computername)
set wsxOut = .stdout
do: wscript.sleep 10
do until wsxOut.atendofstream
line = wsxOut.readline
if re.test(line) then
MyIPAddress = re.execute(line)(0).submatches(0)
end if
loop
loop until .status <> 0 and wsxOut.atendofstream
end with

end function


--
Michael Harris
Microsoft.MVP.Scripting

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Cheech Chong

unread,
Oct 1, 2003, 5:38:40 PM10/1/03
to
On Wed, 1 Oct 2003 13:27:58 -0700, "Michael Harris \(MVP\)"
<mik...@mvps.org> wrote:

>> I will be trying this command line shortly (after reading some
>> previous newsgroup posts about cscript and wscript):
>> C:\WINDOWS\system32\cscript.exe C:\get-ip.vbs //B //T:180
>>
>I would do
>
>%comspec% /c cscript.exe C:\get-ip.vbs //B > c:\get-ip.output.txt
>
>That way any error message written to standard output won't be lost...
>

Michael,
I'll try the redirect to get-ip.output.txt to see what happens when
the script fails to stop. I don't think I mentioned that the script
will run properly in the Scheduled Tasks for 3-4 days, but then it
just stays running (as per the Scheduled Tasks --> view log).

>
>
>> Below is the entire IP script
>
>
>Here's a simpler way to get your own IP address by pinging your own machine
>name...
>
>wscript.echo myipaddress
>

When beind a router, the IP Address on your local machine (normally a
192.168.x.x number) isn't your internet (WAN ip address). For
machines that are directly connected to the internet, I use a .bat
script that runs ipconfig and greps for the line IP Address:.....

--CC

Mark_Pryor

unread,
Oct 2, 2003, 5:40:38 PM10/2/03
to
Hi CC,
"Cheech Chong" <us...@host.com> wrote in message
news:hvvcnv8b837jb4eht...@4ax.com...
> Hello all.
> I've been working on a WSH script to find the Internet IP address my
> LAN has and save it to a file. I've added some error checking and
> timeout features to my original script after finding code snippets on
> the internet.
> I still seem to have a basic problem with the script running the
> Windows XP Scheduled Tasks....
>


> Below is the entire IP script

> --CC
>
>
> ' ######## Start of WhatIsMyIp script #######
> dim oXML, oFSO, oFile
> dim strOutFile, strOpenURL, strTimeDate, strHTML
> dim intTimeout, i
>
> ' strOutFile is the file that the IP address will be written to
> strOutFile="c:\ext-ip.txt"
>
> ' strOpenURL is the Website to find your IP address from
> strOpenURL="http://www.whatismyip.com"
>

Using a third-party site to echo back your IP address introduces
complexity/uncertainty to the success of your script.

Your router should have an admin/status page. I've had good
results parsing my IP out of that HTML, the only difference
being that you need to provide the username/pwd of the admin page.
The oXML.Open() method has arguments for those.

If there is any possiblity that whatismyip.com is filtering
(with CGI scripts) some clients requests, then you should be
better off requesting from your own router, from within your own LAN.

hth,
Mark Pryor


0 new messages