[wpkg-users] WPKG and WOL (WAS: Re: Global max execution time hardcoded?)

heiko.helmle at horiba.com heiko.helmle at horiba.com
Thu Apr 4 10:22:08 CEST 2013


wpkg-users-bounces at lists.wpkg.org wrote on 04.04.2013 09:54:28:

> > An agent would be the best way, so the agent would notify the user
> > of the maintenance and the user could delay it for some time.

I solved parts of the problem with a little script that runs as SYSTEM but 
after a user logs in. It solves two major complains my users had:

* WPKG-GP delays the boot quite significantly (waiting for the network to 
start mostly) even if it doesn't actually install anything.
* For mobiles (Notebooks) WPKG-GP delays boot up to 10 minutes in some 
cases trying to find the home network.

So I figured that you can deactivate WPKG-GP with a registry switch and 
hacked a little script around that:

------------
@echo off
setlocal EnableDelayedExpansion
set SERVER=\\myserver\wpkg
set SCRIPTPATH=!SERVER!\wpkg\wpkg.js
set USER=DOMAINUSER\WPKGUSER
set PASS=WPKGPASSWORD
set LOGFILE="%TEMP%\wpkg-activator.log"
set MSG="%TEMP%\wpkg-activator-message.txt"
set NEWLINE=^


rem two empty lines needed above - this trick generates a newline in a 
variable
echo "WPKG-Activator log" > !LOGFILE!
echo "Mounting Share !SERVER!" >> !LOGFILE!
net use !SERVER! !PASS! /USER:!USER! >>!LOGFILE! 2>&1
set RC=!ERRORLEVEL!
if !RC! NEQ 0 ( echo "Error !RC! returned while trying to mount !SERVER!" 
>> !LOGFILE! 
        echo "Assuming PC is not in the local network" >> !LOGFILE!
        goto deactivate
)
echo "Running wpkg query ( !SCRIPTPATH! )" >> !LOGFILE!
FOR /F "delims=: tokens=1* skip=1" %%A IN ('cscript /NoLogo /E:Jscript 
!SCRIPTPATH! /synchronize /query:uI') DO (
        if not "%%A" == "Report Packaging Errors" (
                if [%%B] == [] ( set PACKAGES=!PACKAGES!!NEWLINE!* %%A )
                set action=%%B
                set _dummy=!action:pending=!
                IF NOT [!_dummy!] == [!action!] set install=true
        )
)


IF "%install%" == "true" ( GOTO activate ) else ( goto deactivate )
echo here be dragons!
goto ende

:activate
echo Pending packages found: >> !LOGFILE!
echo !PACKAGES! >> !LOGFILE!
echo Activating WPKGGP >> !LOGFILE!
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows 
NT\CurrentVersion\Winlogon\GPExtensions\{A9B8D792-F454-11DE-BA92-FDCF56D89593}" 
/v NoMachinePolicy /f >NUL 2>&1
echo WPKG found the following packages pending upgrade or installation: 
!NEWLINE!!PACKAGES!!NEWLINE!!NEWLINE!On-Boot installation is activated. 
Packages will be installed on the next boot. > !MSG!
MSG * /TIME:3600 < !MSG! >> !LOGFILE! 2>&1
del !MSG!

goto ende

:deactivate
echo Deactivating WPKGGP >> !LOGFILE!
rem This registry key will disable running WPKG on boot
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows 
NT\CurrentVersion\Winlogon\GPExtensions\{A9B8D792-F454-11DE-BA92-FDCF56D89593}" 
/v NoMachinePolicy /t REG_DWORD /d 1 /f >NUL


:ende
echo "Unmounting wpkg-share" >> !LOGFILE!
NET USE /DELETE !SERVER! >> !LOGFILE!
--------------

This script does:
* Try to connect to the server - if this fails it assumes that it is not 
in the local network -> Deactivate WPKG-GP
* If connect is successful run wpkg-query for upgrades and installs. If 
this returns anything then
        * MSG all logged in users that installs are pending on the next 
boot
        * Activate WPKG-GP
        -- It ignores the special package "Report Packaging Errors" that 
is specific to my installation (this packages mails the WPKG-Log to me if 
any error occured during the WPKG run)
* If no pending packages are found, deactivate WPKG-GP

Now put this script in the task manager to run at logon of a user and it 
will - after logon - inform the user that installs are pending. Most of my 
users take this hint and just trigger a reboot before going to lunch. Some 
others ignore it and get the installs on the next morning when booting 
(because WPKG-GP is now active). Only some of those users who only 
"Hibernate" their machines won't get any packages. In that case I chose to 
schedule the script every hour. Nagging works.

There are some corner cases of course, but at least in our environment 
this works reasonably well and maybe you can adapt it for you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/wpkg-users/attachments/20130404/176da62b/attachment-0003.html>


More information about the wpkg-users mailing list