Jump to content

Windows 10 - VBScript Not Running During Logoff via GPO


Recommended Posts

Posted (edited)

Hi All,

 

I hope someone can help me with this as I cannot find the answer anywhere.

 

We currently have a working .vbs script for Windows 7 that simply displays a message box when a user logs off: "Did you punch out?" with "Yes" or "No" buttons. If the user selects "No", Internet Explorer opens up with our punch in/out website. If "Yes" is selected, logoff/shutdown continues as normal. This script is applied via group policy: User Config>policies>Windows settings>scripts>logoff

 

Now the Windows 10 problem: during shutdown, restart, and logoff, the box does not appear. The shutdown/restart/logoff screen (which ever was chosen) gets stuck for 5 minutes, then eventually shuts down.

 

If I run the script manually on the computer, the message box appears and correctly opens Internet Explorer with the website, therefor the script does work, just not automatically during the logoff.

I have already tried to disable fast startup from the power options as I read on another forum, this can cause scripts during shutdown to not run properly. The computer is getting the correct group policy as well as it is shown in gpresult. Disabling the policy causes logoff and shutdown to take about 3 seconds like it should.

 

I should also mention we have a similar logon script that works fine in Windows 10. The only difference is that is simply opens up the punch in/out website, no message box. Its just the logoff script that is not working. I believe it is because Windows 10 is displaying the shutdown screen too quickly and we cannot see the message box.

 

Here is the screen that gets hung for 5 minutes:

windows-10-shutting-down-featured.png

 

Here is the .vbs script (edited out url for privacy)

 

Set objExplorer = CreateObject("InternetExplorer.Application")

 

 

intAnswer = _

Msgbox("Did you punch out?", 36, "Time System")

 

 

If intAnswer = vbNo Then

Set objExplorer = WScript.CreateObject _

("InternetExplorer.Application", "IE_")

objExplorer.Navigate "https://linktotimesystem.com"

objExplorer.Visible = true

objExplorer.ToolBar = true

objExplorer.MenuBar = true

objExplorer.StatusBar = true

objExplorer.AddressBar = true

objExplorer.Width = 800

objExplorer.Height = 600

objExplorer.Left = 0

objExplorer.Top = 0

objExplorer.Resizable = true

wscript.sleep 2000

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!" & strComputer& "\root\cimv2")

Set colServices = objWMIService.ExecQuery _

("SELECT * FROM Win32_Service")

For Each objService in colServices

Wscript.Sleep 2000

Next

Sub IE_onQuit()

Wscript.Quit

End Sub

Else

 

 

End If

Edited by scottc816

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...