Dear All,
I have produced the following script which when run (usually by
TaskScheduler at 6pm each day). It opens an IE page, shows an animated clock,
tells the user to click a button if they don't want the computer to shut down
after 30 seconds. If they don't click the button, then the PC shuts down. If
they do the script quits.

All the parts of the script work except the input button. Including this
line gives the error:

Line 31, Char 53, error Expected end of statement, code 800A0401, MS VBS
compliation error.

Any ideas what's wrong with this line?

If I ' the line out it works just fine.
======================== Shut Down Scriipt ==========
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
"\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM
Win32_OperatingSystem")
Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next

Set objExplorer = CreateObject _
("InternetExplorer.Application")

objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Left = (intHorizontal - 400) / 2
objExplorer.Top = (intVertical - 200) / 2
objExplorer.Width = 400
objExplorer.Height = 200
objExplorer.Visible = 1

objExplorer.Document.Body.Style.Cursor = "wait"

objExplorer.Document.Title = "Logon script in progress"
objExplorer.Document.Body.InnerHTML = "<img
src='file:///E:\Artwork\Animations\MinuteClock.gif'> " & _
"This computer will SHUT DOWN in 30 Seconds. To cancel Shutdown please
click the STOP button"

objExplorer.Document.Body.InnerHTML = "<input type="button" value="STOP"
onClick="QuitScript">" 'this line stops the script working..

Wscript.Sleep 30000 'currently set to 30 seconds

objExplorer.Document.Body.InnerHTML = "Computer will now shut down.
Goodbye..."

'Lines below tabbed out for testing purposes.

'For Each objOperatingSystem in colOperatingSystems
' objOperatingSystem.Shutdown()
'Next

Sub QuitScript

Wscript.Quit

End Sub
=========================== End =====================

Thanks in advance for any help provided.
--
Cheers
Chas

***************
* Spectrum is Green *
***************

Re: Create a Shutdown script that gives a user the chance to quit. by JTW

JTW
Fri Sep 15 10:37:26 CDT 2006

I think it is actually the line that starts
'objExplorer.Document.Body.InnerHTML = "<input type=" ' - Check your
use of quote characters.

--
Jase T. Wolfe
Dx21, LLC
http://www.Dx21.com


Chas Large wrote:

> Dear All,
> I have produced the following script which when run (usually by
> TaskScheduler at 6pm each day). It opens an IE page, shows an
> animated clock, tells the user to click a button if they don't want
> the computer to shut down after 30 seconds. If they don't click the
> button, then the PC shuts down. If they do the script quits.
>
> All the parts of the script work except the input button. Including
> this line gives the error:
>
> Line 31, Char 53, error Expected end of statement, code 800A0401, MS
> VBS compliation error.
>
> Any ideas what's wrong with this line?
>
> If I ' the line out it works just fine.
> ======================== Shut Down Scriipt ==========
> On Error Resume Next
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
> "\root\cimv2")
> Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM
> Win32_OperatingSystem")
> Set objWMIService = GetObject("Winmgmts:\\" & strComputer &
> "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From
> Win32_DesktopMonitor") For Each objItem in colItems
> intHorizontal = objItem.ScreenWidth
> intVertical = objItem.ScreenHeight
> Next
>
> Set objExplorer = CreateObject _
> ("InternetExplorer.Application")
>
> objExplorer.Navigate "about:blank"
> objExplorer.ToolBar = 0
> objExplorer.StatusBar = 0
> objExplorer.Left = (intHorizontal - 400) / 2
> objExplorer.Top = (intVertical - 200) / 2
> objExplorer.Width = 400
> objExplorer.Height = 200
> objExplorer.Visible = 1
>
> objExplorer.Document.Body.Style.Cursor = "wait"
>
> objExplorer.Document.Title = "Logon script in progress"
> objExplorer.Document.Body.InnerHTML = "<img
> src='file:///E:\Artwork\Animations\MinuteClock.gif'> " & _
> "This computer will SHUT DOWN in 30 Seconds. To cancel Shutdown
> please click the STOP button"
>
> objExplorer.Document.Body.InnerHTML = "<input type="button"
> value="STOP" onClick="QuitScript">" 'this line stops the script
> working..
>
> Wscript.Sleep 30000 'currently set to 30 seconds
>
> objExplorer.Document.Body.InnerHTML = "Computer will now shut down.
> Goodbye..."
>
> 'Lines below tabbed out for testing purposes.
>
> 'For Each objOperatingSystem in colOperatingSystems
> ' objOperatingSystem.Shutdown()
> 'Next
>
> Sub QuitScript
>
> Wscript.Quit
>
> End Sub
> =========================== End =====================
>
> Thanks in advance for any help provided.

Re: Create a Shutdown script that gives a user the chance to quit. by JHP

JHP
Fri Sep 15 11:13:46 CDT 2006

Single quotes: objExplorer.Document.Body.InnerHTML = "<input type='button'
value='STOP' onClick='QuitScript'>"


"JTW" <Newsgroup@Dx21.com> wrote in message
news:e3$kZzN2GHA.4476@TK2MSFTNGP02.phx.gbl...
>I think it is actually the line that starts
> 'objExplorer.Document.Body.InnerHTML = "<input type=" ' - Check your
> use of quote characters.
>
> --
> Jase T. Wolfe
> Dx21, LLC
> http://www.Dx21.com
>
>
> Chas Large wrote:
>
>> Dear All,
>> I have produced the following script which when run (usually by
>> TaskScheduler at 6pm each day). It opens an IE page, shows an
>> animated clock, tells the user to click a button if they don't want
>> the computer to shut down after 30 seconds. If they don't click the
>> button, then the PC shuts down. If they do the script quits.
>>
>> All the parts of the script work except the input button. Including
>> this line gives the error:
>>
>> Line 31, Char 53, error Expected end of statement, code 800A0401, MS
>> VBS compliation error.
>>
>> Any ideas what's wrong with this line?
>>
>> If I ' the line out it works just fine.
>> ======================== Shut Down Scriipt ==========
>> On Error Resume Next
>>
>> strComputer = "."
>> Set objWMIService = GetObject("winmgmts:" &
>> "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
>> "\root\cimv2")
>> Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM
>> Win32_OperatingSystem")
>> Set objWMIService = GetObject("Winmgmts:\\" & strComputer &
>> "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From
>> Win32_DesktopMonitor") For Each objItem in colItems
>> intHorizontal = objItem.ScreenWidth
>> intVertical = objItem.ScreenHeight
>> Next
>>
>> Set objExplorer = CreateObject _
>> ("InternetExplorer.Application")
>>
>> objExplorer.Navigate "about:blank"
>> objExplorer.ToolBar = 0
>> objExplorer.StatusBar = 0
>> objExplorer.Left = (intHorizontal - 400) / 2
>> objExplorer.Top = (intVertical - 200) / 2
>> objExplorer.Width = 400
>> objExplorer.Height = 200
>> objExplorer.Visible = 1
>>
>> objExplorer.Document.Body.Style.Cursor = "wait"
>>
>> objExplorer.Document.Title = "Logon script in progress"
>> objExplorer.Document.Body.InnerHTML = "<img
>> src='file:///E:\Artwork\Animations\MinuteClock.gif'> " & _
>> "This computer will SHUT DOWN in 30 Seconds. To cancel Shutdown
>> please click the STOP button"
>>
>> objExplorer.Document.Body.InnerHTML = "<input type="button"
>> value="STOP" onClick="QuitScript">" 'this line stops the script
>> working..
>>
>> Wscript.Sleep 30000 'currently set to 30 seconds
>>
>> objExplorer.Document.Body.InnerHTML = "Computer will now shut down.
>> Goodbye..."
>>
>> 'Lines below tabbed out for testing purposes.
>>
>> 'For Each objOperatingSystem in colOperatingSystems
>> ' objOperatingSystem.Shutdown()
>> 'Next
>>
>> Sub QuitScript
>>
>> Wscript.Quit
>>
>> End Sub
>> =========================== End =====================
>>
>> Thanks in advance for any help provided.



Re: Create a Shutdown script that gives a user the chance to quit. by ChasLarge

ChasLarge
Fri Sep 15 11:15:02 CDT 2006

Dear JTW, I am not sure if this line is wholly incorrect, I took it from
another working script that I found on the script centre. I know that if it
is removed the script runs OK but the line looks OK. I have tried it without
the quotes and without the <> tag enclosures but each time the error occurs.
I'm not sure how the web page appears to you but the part in brackets look
like:

"<input type="button" value="STOP" onClick="QuitScript">"

This works on a web page without the quotes so I think it's OK.
--
Cheers
Chas

***************
* Spectrum is Green *
***************


"JTW" wrote:

> I think it is actually the line that starts
> 'objExplorer.Document.Body.InnerHTML = "<input type=" ' - Check your
> use of quote characters.
>
> --
> Jase T. Wolfe
> Dx21, LLC
> http://www.Dx21.com
>
>
> Chas Large wrote:
>
> > Dear All,
> > I have produced the following script which when run (usually by
> > TaskScheduler at 6pm each day). It opens an IE page, shows an
> > animated clock, tells the user to click a button if they don't want
> > the computer to shut down after 30 seconds. If they don't click the
> > button, then the PC shuts down. If they do the script quits.
> >
> > All the parts of the script work except the input button. Including
> > this line gives the error:
> >
> > Line 31, Char 53, error Expected end of statement, code 800A0401, MS
> > VBS compliation error.
> >
> > Any ideas what's wrong with this line?
> >
> > If I ' the line out it works just fine.
> > ======================== Shut Down Scriipt ==========
> > On Error Resume Next
> >
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" &
> > "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
> > "\root\cimv2")
> > Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM
> > Win32_OperatingSystem")
> > Set objWMIService = GetObject("Winmgmts:\\" & strComputer &
> > "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From
> > Win32_DesktopMonitor") For Each objItem in colItems
> > intHorizontal = objItem.ScreenWidth
> > intVertical = objItem.ScreenHeight
> > Next
> >
> > Set objExplorer = CreateObject _
> > ("InternetExplorer.Application")
> >
> > objExplorer.Navigate "about:blank"
> > objExplorer.ToolBar = 0
> > objExplorer.StatusBar = 0
> > objExplorer.Left = (intHorizontal - 400) / 2
> > objExplorer.Top = (intVertical - 200) / 2
> > objExplorer.Width = 400
> > objExplorer.Height = 200
> > objExplorer.Visible = 1
> >
> > objExplorer.Document.Body.Style.Cursor = "wait"
> >
> > objExplorer.Document.Title = "Logon script in progress"
> > objExplorer.Document.Body.InnerHTML = "<img
> > src='file:///E:\Artwork\Animations\MinuteClock.gif'> " & _
> > "This computer will SHUT DOWN in 30 Seconds. To cancel Shutdown
> > please click the STOP button"
> >
> > objExplorer.Document.Body.InnerHTML = "<input type="button"
> > value="STOP" onClick="QuitScript">" 'this line stops the script
> > working..
> >
> > Wscript.Sleep 30000 'currently set to 30 seconds
> >
> > objExplorer.Document.Body.InnerHTML = "Computer will now shut down.
> > Goodbye..."
> >
> > 'Lines below tabbed out for testing purposes.
> >
> > 'For Each objOperatingSystem in colOperatingSystems
> > ' objOperatingSystem.Shutdown()
> > 'Next
> >
> > Sub QuitScript
> >
> > Wscript.Quit
> >
> > End Sub
> > =========================== End =====================
> >
> > Thanks in advance for any help provided.
>

Re: Create a Shutdown script that gives a user the chance to quit. by ChasLarge

ChasLarge
Mon Sep 18 03:04:02 CDT 2006

Dear JHP & JTW,
Thanks for your help. Single quotes did the trick.
--
Cheers
Chas

***************
* Spectrum is Green *
***************


"JHP" wrote:

> Single quotes: objExplorer.Document.Body.InnerHTML = "<input type='button'
> value='STOP' onClick='QuitScript'>"
>
>
> "JTW" <Newsgroup@Dx21.com> wrote in message
> news:e3$kZzN2GHA.4476@TK2MSFTNGP02.phx.gbl...
> >I think it is actually the line that starts
> > 'objExplorer.Document.Body.InnerHTML = "<input type=" ' - Check your
> > use of quote characters.
> >
> > --
> > Jase T. Wolfe
> > Dx21, LLC
> > http://www.Dx21.com
> >
> >
> > Chas Large wrote:
> >
> >> Dear All,
> >> I have produced the following script which when run (usually by
> >> TaskScheduler at 6pm each day). It opens an IE page, shows an
> >> animated clock, tells the user to click a button if they don't want
> >> the computer to shut down after 30 seconds. If they don't click the
> >> button, then the PC shuts down. If they do the script quits.
> >>
> >> All the parts of the script work except the input button. Including
> >> this line gives the error:
> >>
> >> Line 31, Char 53, error Expected end of statement, code 800A0401, MS
> >> VBS compliation error.
> >>
> >> Any ideas what's wrong with this line?
> >>
> >> If I ' the line out it works just fine.
> >> ======================== Shut Down Scriipt ==========
> >> On Error Resume Next
> >>
> >> strComputer = "."
> >> Set objWMIService = GetObject("winmgmts:" &
> >> "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
> >> "\root\cimv2")
> >> Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM
> >> Win32_OperatingSystem")
> >> Set objWMIService = GetObject("Winmgmts:\\" & strComputer &
> >> "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From
> >> Win32_DesktopMonitor") For Each objItem in colItems
> >> intHorizontal = objItem.ScreenWidth
> >> intVertical = objItem.ScreenHeight
> >> Next
> >>
> >> Set objExplorer = CreateObject _
> >> ("InternetExplorer.Application")
> >>
> >> objExplorer.Navigate "about:blank"
> >> objExplorer.ToolBar = 0
> >> objExplorer.StatusBar = 0
> >> objExplorer.Left = (intHorizontal - 400) / 2
> >> objExplorer.Top = (intVertical - 200) / 2
> >> objExplorer.Width = 400
> >> objExplorer.Height = 200
> >> objExplorer.Visible = 1
> >>
> >> objExplorer.Document.Body.Style.Cursor = "wait"
> >>
> >> objExplorer.Document.Title = "Logon script in progress"
> >> objExplorer.Document.Body.InnerHTML = "<img
> >> src='file:///E:\Artwork\Animations\MinuteClock.gif'> " & _
> >> "This computer will SHUT DOWN in 30 Seconds. To cancel Shutdown
> >> please click the STOP button"
> >>
> >> objExplorer.Document.Body.InnerHTML = "<input type="button"
> >> value="STOP" onClick="QuitScript">" 'this line stops the script
> >> working..
> >>
> >> Wscript.Sleep 30000 'currently set to 30 seconds
> >>
> >> objExplorer.Document.Body.InnerHTML = "Computer will now shut down.
> >> Goodbye..."
> >>
> >> 'Lines below tabbed out for testing purposes.
> >>
> >> 'For Each objOperatingSystem in colOperatingSystems
> >> ' objOperatingSystem.Shutdown()
> >> 'Next
> >>
> >> Sub QuitScript
> >>
> >> Wscript.Quit
> >>
> >> End Sub
> >> =========================== End =====================
> >>
> >> Thanks in advance for any help provided.
>
>
>