<tt><font size=2>wpkg-users-bounces@lists.wpkg.org wrote on 04.04.2013
09:54:28:<br>
<br>
> > An agent would be the best way, so the agent would notify the
user<br>
> > of the maintenance and the user could delay it for some time.<br>
</font></tt>
<br><tt><font size=2>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:</font></tt>
<br>
<br><tt><font size=2>* WPKG-GP delays the boot quite significantly (waiting
for the network to start mostly) even if it doesn't actually install anything.</font></tt>
<br><tt><font size=2>* For mobiles (Notebooks) WPKG-GP delays boot up to
10 minutes in some cases trying to find the home network.</font></tt>
<br>
<br><tt><font size=2>So I figured that you can deactivate WPKG-GP with
a registry switch and hacked a little script around that:</font></tt>
<br>
<br><tt><font size=2>------------</font></tt>
<br><tt><font size=2>@echo off</font></tt>
<br><tt><font size=2>setlocal EnableDelayedExpansion</font></tt>
<br><tt><font size=2>set SERVER=\\myserver\wpkg</font></tt>
<br><tt><font size=2>set SCRIPTPATH=!SERVER!\wpkg\wpkg.js</font></tt>
<br><tt><font size=2>set USER=DOMAINUSER\WPKGUSER</font></tt>
<br><tt><font size=2>set PASS=WPKGPASSWORD</font></tt>
<br><tt><font size=2>set LOGFILE="%TEMP%\wpkg-activator.log"</font></tt>
<br><tt><font size=2>set MSG="%TEMP%\wpkg-activator-message.txt"</font></tt>
<br><tt><font size=2>set NEWLINE=^</font></tt>
<br>
<br>
<br><tt><font size=2>rem two empty lines needed above - this trick generates
a newline in a variable</font></tt>
<br><tt><font size=2>echo "WPKG-Activator log" > !LOGFILE!</font></tt>
<br><tt><font size=2>echo "Mounting Share !SERVER!" >>
!LOGFILE!</font></tt>
<br><tt><font size=2>net use !SERVER! !PASS! /USER:!USER! >>!LOGFILE!
2>&1</font></tt>
<br><tt><font size=2>set RC=!ERRORLEVEL!</font></tt>
<br><tt><font size=2>if !RC! NEQ 0 ( echo "Error !RC! returned while
trying to mount !SERVER!" >> !LOGFILE! </font></tt>
<br><tt><font size=2> echo "Assuming
PC is not in the local network" >> !LOGFILE!</font></tt>
<br><tt><font size=2> goto deactivate</font></tt>
<br><tt><font size=2>)</font></tt>
<br><tt><font size=2>echo "Running wpkg query ( !SCRIPTPATH! )"
>> !LOGFILE!</font></tt>
<br><tt><font size=2>FOR /F "delims=: tokens=1* skip=1" %%A IN
('cscript /NoLogo /E:Jscript !SCRIPTPATH! /synchronize /query:uI') DO (</font></tt>
<br><tt><font size=2> if not "%%A"
== "Report Packaging Errors" (</font></tt>
<br><tt><font size=2>
if [%%B] == [] ( set PACKAGES=!PACKAGES!!NEWLINE!*
%%A )</font></tt>
<br><tt><font size=2>
set action=%%B</font></tt>
<br><tt><font size=2>
set _dummy=!action:pending=!</font></tt>
<br><tt><font size=2>
IF NOT [!_dummy!] == [!action!] set install=true</font></tt>
<br><tt><font size=2> )</font></tt>
<br><tt><font size=2>)</font></tt>
<br>
<br>
<br><tt><font size=2>IF "%install%" == "true" ( GOTO
activate ) else ( goto deactivate )</font></tt>
<br><tt><font size=2>echo here be dragons!</font></tt>
<br><tt><font size=2>goto ende</font></tt>
<br>
<br><tt><font size=2>:activate</font></tt>
<br><tt><font size=2>echo Pending packages found: >> !LOGFILE!</font></tt>
<br><tt><font size=2>echo !PACKAGES! >> !LOGFILE!</font></tt>
<br><tt><font size=2>echo Activating WPKGGP >> !LOGFILE!</font></tt>
<br><tt><font size=2>reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon\GPExtensions\{A9B8D792-F454-11DE-BA92-FDCF56D89593}"
/v NoMachinePolicy /f >NUL 2>&1</font></tt>
<br><tt><font size=2>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!</font></tt>
<br><tt><font size=2>MSG * /TIME:3600 < !MSG! >> !LOGFILE! 2>&1</font></tt>
<br><tt><font size=2>del !MSG!</font></tt>
<br>
<br><tt><font size=2>goto ende</font></tt>
<br>
<br><tt><font size=2>:deactivate</font></tt>
<br><tt><font size=2>echo Deactivating WPKGGP >> !LOGFILE!</font></tt>
<br><tt><font size=2>rem This registry key will disable running WPKG on
boot</font></tt>
<br><tt><font size=2>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</font></tt>
<br>
<br>
<br><tt><font size=2>:ende</font></tt>
<br><tt><font size=2>echo "Unmounting wpkg-share" >> !LOGFILE!</font></tt>
<br><tt><font size=2>NET USE /DELETE !SERVER! >> !LOGFILE!</font></tt>
<br><tt><font size=2>--------------</font></tt>
<br>
<br><tt><font size=2>This script does:</font></tt>
<br><tt><font size=2>* Try to connect to the server - if this fails it
assumes that it is not in the local network -> Deactivate WPKG-GP</font></tt>
<br><tt><font size=2>* If connect is successful run wpkg-query for upgrades
and installs. If this returns anything then</font></tt>
<br><tt><font size=2> * MSG all logged
in users that installs are pending on the next boot</font></tt>
<br><tt><font size=2> * Activate WPKG-GP</font></tt>
<br><tt><font size=2> -- 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)</font></tt>
<br><tt><font size=2>* If no pending packages are found, deactivate WPKG-GP</font></tt>
<br>
<br><tt><font size=2>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.</font></tt>
<br>
<br><tt><font size=2>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.</font></tt>