• Welcome to Support Forum: Get Support for Patch My PC Products and Services.
 

Enhancement: Pre/Post Scripts

Started by grmorgan618, January 17, 2019, 07:38:45 AM

Previous topic - Next topic

grmorgan618

I haven't had any time to look at the pre/post scripts yet so I had some questions... and if the answers are no, then emerges my enhancement requests....

1 - am I able to fail the patch from the pre-script? ... for instances,  if my pre-script returns a greater than 0 return code does the patch fail?
* my goal is to put logic in my pre script so I skip(fail) updates until the deadline, then kill processes but I want my pre-script to handle it - not be static like the publishing options are.

2 - is any information about the currently running update (product and version) passed to the pre/post scripts as arguments?
* my goal is to make a single dynamic pre/post script based on the product and when needed the version. in simple usage, a single script for all products that utilized a switch/case function (or ... :) since I see PatchMyPC is written in Vb.net Select/Case ...)


Justin Chalfant (Patch My PC)

Quote from: grmorgan618 on January 17, 2019, 07:38:45 AM
I haven't had any time to look at the pre/post scripts yet so I had some questions... and if the answers are no, then emerges my enhancement requests....

1 - am I able to fail the patch from the pre-script? ... for instances,  if my pre-script returns a greater than 0 return code does the patch fail?
* my goal is to put logic in my pre script so I skip(fail) updates until the deadline, then kill processes but I want my pre-script to handle it - not be static like the publishing options are.

I'm like 98% sure, we don't consider a pre/post script non-exit code of 0 a failure. The patch will return the exit code of the main installer regardless of the exit code of the pre/post script. I totally get where having an option to NOT proceed with the main update <IF> the pre-script gives a non-exit code of 0 could be helpful in some cases. From a coding side, I think we could add a checkbox in the pre/post script dialog for each product that says something like "Don't attempt software update if the pre-update script returns an exit code other than 0."


Quote from: grmorgan618 on January 17, 2019, 07:38:45 AM2 - is any information about the currently running update (product and version) passed to the pre/post scripts as arguments?
* my goal is to make a single dynamic pre/post script based on the product and when needed the version. in simple usage, a single script for all products that utilized a switch/case function (or ... :) since I see PatchMyPC is written in Vb.net Select/Case ...)

All actions for the wrapper we have is logged to "C:\Windows\CCM\Logs\PatchMyPC-ScriptRunner.log". This includes update, pre/post scripts, regkeys, etc.


grmorgan618

Thanks for the answers Justin -- appreciate the quick responses!

For question 2, ... if I have a pre-script and post-script set... does that script get passed any parameters from scriptrunner?
My question/request is more that
ScriptRunner would call my script like this
Script.ps1 "Adobe Reader" "37.0.1"

Justin Chalfant (Patch My PC)

Ah, I see. We don't support custom parameters for the script it just runs the script file. This is probably something we could support in a future update though. I will add this to the radar.

grmorgan618

Awesome - this would really enable me to do some cool integration with the updates.. Especially if you allowed me to define the parameters :)
"Parameters to pass to ScriptRunner"... then allow me to define them from all the fields
%ProductName% %ProductVersion% %CVENumber% 

In the mean time, I'll work through tracing the parent processes and seeing what type of information i can pull out of those to help feed this.

Thanks Again!

Justin Chalfant (Patch My PC)

Does this look like what you had in mind?


grmorgan618

Awesome - yup that will work for me.

Justin Chalfant (Patch My PC)

Cool, this build will most likely release sometime this week.

Justin Chalfant (Patch My PC)

We will support script parameters in the next update.