config waptexit to execute on shutdown, not on reboot

Share your tips or issues concerning the WAPT Console or WAPT Agent here
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
erict
Messages: 56
Registration: December 22, 2017 - 7:09 PM

June 29, 2018 - 12:05

Hello,

I'm using WAPT version 1.5.
I admit I haven't (re)read all the documentation, and a search for "waptexit" on the forum didn't yield any conclusive results. If a similar discussion already exists, please feel free to redirect me to it.

I wanted to know if it's possible to modify WAPTEXIT's behavior so that it only launches when the computer is shut down, but not on reboot?

And if not, I would suggest that this be configurable in a future version, if possible.

I disable the user's ability to prevent its execution; it seems safer to me, but on the other hand, if we could avoid wasting time on a reboot, that would be quite useful (for use in labs).

Regards,
ET
erict
Messages: 56
Registration: December 22, 2017 - 7:09 PM

July 3, 2018 - 10:43

Hello,

No response... What am I to conclude?
Did I phrase the question badly? "Look it up yourself, it's already in the documentation"? Taboo question?...
I imagine the answer, at least to my first question, must be no.
For the second, I'll take a look at the code... you never know.

Good luck.
AND

PS: No criticism intended in this post, which I realize could be taken the wrong way. I know what it's like to manage a stream of user requests... there are priorities ;-). This is just a last-ditch "bump."
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

July 3, 2018 - 2:34 PM

Hello,
I don't know if it's possible to know when a script is launched during a machine shutdown if the shutdown is triggered by a reboot...
Waptexit is actually just an application launched by a local GPO: Scripts > Shutdown > Startup / System Shutdown (run gpedit.msc).
There might be an indicator in the Windows registry to determine the cause of the shutdown...
Apparently: ... here https://stackoverflow.com/questions/106 ... s-actually

The question then becomes whether this information is available when the shutdown script runs or only afterward...

If it's available, then we should be able to add a condition to Waptexit...
Tranquil IT
erict
Messages: 56
Registration: December 22, 2017 - 7:09 PM

July 6, 2018 - 2:56 PM

Thanks for the reply...
I'll look into it further and let you know if I find anything.

Best regards
, ET
erict
Messages: 56
Registration: December 22, 2017 - 7:09 PM

April 10, 2019 - 2:20 PM

Good morning,

It's been a long time since my last message, but I hadn't had time to look into it...

So, regarding detecting whether the computer is restarting or shutting down, a small PowerShell script does that very well:

Code: Select all

$systemLastShutdownType = get-eventlog -Logname system -Source User32 | ?{$_.eventid -eq 1074} | select -first 1
$logfile = "C:\Windows\Temp\waptgpostd.log"
$logfilerr = "C:\Windows\Temp\waptgpoerr.log"
switch -regex ($systemLastShutdownType.message) {
	".*Red.*marrer.*" {"restart" > $logfile}
	default {Start-Process -FilePath "C:\Program Files (x86)\wapt\waptexit.exe" -Wait -RedirectStandardOutput $logfile -RedirectStandardError $logfilerr }
I tested it by replacing the GPO installed by WAPT (waptexit) with the launch of this script, and it works well (a powershell window opens when the PC is shut down or rebooted, which is very ugly, but it does not prevent operation, and it should be possible to eliminate it, by searching carefully).

So this could be a configurable option in a future version of WAPT, with little code change (but I suspect there are probably other priorities, especially since my code only works with French versions of Windows).

I just wanted to add to this post by sharing the answer I found. Now I just need to figure out how to modify the GPOs using PowerShell and create a WAPT package that automatically configures my machines.

AND.
erict
Messages: 56
Registration: December 22, 2017 - 7:09 PM

April 11, 2019 - 1:35 PM

Okay

, so I need a couple of things:

I can see the waptexit script running as a shutdown script in gpedit.msc on my computers.
But I can't find a way to delete, replace, or modify it.
I've modified all the registry entries (I found four) related to waptexit, but the script still appears in gpedit.
However, waptexit no longer runs, neither when the computer shuts down nor reboots. And if I replace waptexit with my script in the registry, the behavior is still the same (no waptexit, but my script doesn't run either).
If I do the same thing (replace waptexit with my script) through gpedit.msc, though, it works as expected.

In short, I've searched on Google, but I can't find a solution to this problem.

Finally, I figured that if you know how to add waptexit, you should probably be able to give me the necessary pointers to do the same with my script ;-). Might as well go straight to the source.

Of course, the goal is to script all of this. As I said earlier, by clicking in gpedit.msc, I already know how to do it...

Thanks in advance if anyone can shed some light on this.

Sincerely,
ET
Locked