[wpkg-users] WPKG Client modified to run at Windows Vista, 7, 8 shutdown

Krzysztof Gibas service at lukas-bch.com.pl
Thu Jan 30 19:35:39 CET 2014


Hello,

simply put I've modified WPKG service source code to make software
installation at shutdown in Windows Vista and newer possible.

Here http://sdrv.ms/1baxE9K you can download zip file with modified
source code and compiled WPKGSrv.exe. If you want to try this out you
have to overwrite WPKGSrv.exe in Program files\wpkg with this one
(stop WPKG service first). Don't forget to add "PreshutdownTimeout"
(DWORD) in
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\gpsvc] with some
high value (it's in milliseconds). When I will release version with
the installer this will be set at installation time.

Now extended cut :)

I'm a long time Wpkg user. I like it very much. I use it mostly in
small and medium-sized environments. And my favourite way of running
it is definitely at shutdown.

As you know since Vista came and Microsoft implemented new rules for
application and services shutdown WPKG client was ruthlessly killed
after a few seconds of Windows shutdown.

Of course there are ways to work it around:
- you can run scheduled tasks, even late at night, but there are empty
runs if there is nothing to install, you have to maintain additional
account with admin rights in case user changes his password etc.
- you can use group policy, but not on Home edition.

All in all service running at shutdown was still my preferred method
and I prayed that someone adapts it to Windows Vista and newer. :)

I've even posted here more than a year ago but there were no results.
http://lists.wpkg.org/pipermail/wpkg-users/2012-October/009020.html

Time passed by, Windows XP slowly becomes obsolete and I had to do
something. :)

I took a look at the code. Although I'm not a C++ developer it looked
nice.

I've googled around and found almost nothing. When someone asks how to
delay Windows 7 service shutdown people say it's now impossible
because it's bad practice (like they know anything :) ). But Microsoft
himself states otherwise
http://msdn.microsoft.com/en-us/magazine/cc164252.aspx#S2

Through trial and error I found that someone who programmed this
service did nearly everything necessary to delay shutdown in Windows
7 but one key element was missing - service must periodically inform
Service Control Manager that it is alive and still doing its tasks.
So I've added piece of code that starts another thread which
communicates with SCM and then starts WPKGworker (which manages
application installs). Most of my changes start at line 730.
I've tried to adhere to code conventions used in this program.

Right now I haven't found the way to display UI during shutdown
although it's definitely possible as I've seen apps doing this.

I've tested this on Windows 7 and XP.

I'm waiting for your feedback.

Regards,
Chris



More information about the wpkg-users mailing list