Page 1 of 1

config waptexit to execute on shutdown, not on reboot

Published: June 29, 2018 - 12:05 PM
by Eric
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

Re: Configuring waptexit to execute on system shutdown, not reboot

Published: July 3, 2018 - 10:43 AM
by Eric
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."

Re: Configuring waptexit to execute on system shutdown, not reboot

Published: July 3, 2018 - 2:34 PM
by htouvet
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...

Re: Configuring waptexit to execute on system shutdown, not reboot

Published: July 6, 2018 - 2:56 PM
by Eric
Thanks for the reply...
I'll look into it further and let you know if I find anything.

Best regards
, ET

Re: Configuring waptexit to execute on system shutdown, not reboot

Published: April 10, 2019 - 2:20 PM
by Eric
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.

Re: Configuring waptexit to execute on system shutdown, not reboot

Published: April 11, 2019 - 1:35 PM
by Eric
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