Author Topic: Enhancement: Pre/Post Scripts  (Read 601 times)

Offline grmorgan618

  • Newbie
  • *
  • Posts: 26
    • View Profile
Enhancement: Pre/Post Scripts
« 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.

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 ...)


Offline Justin Chalfant

  • Patch My PC Support
  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
    • View Profile
    • Patch My PC Support
Re: Enhancement: Pre/Post Scripts
« Reply #1 on: January 17, 2019, 08:38:25 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."


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 ...)

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.


Offline grmorgan618

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Enhancement: Pre/Post Scripts
« Reply #2 on: January 17, 2019, 09:57:33 AM »
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"

Offline Justin Chalfant

  • Patch My PC Support
  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
    • View Profile
    • Patch My PC Support
Re: Enhancement: Pre/Post Scripts
« Reply #3 on: January 17, 2019, 09:59:12 AM »
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.

Offline grmorgan618

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Enhancement: Pre/Post Scripts
« Reply #4 on: January 17, 2019, 10:05:11 AM »
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!

Offline Justin Chalfant

  • Patch My PC Support
  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
    • View Profile
    • Patch My PC Support
Re: Enhancement: Pre/Post Scripts
« Reply #5 on: January 21, 2019, 08:43:46 AM »
Does this look like what you had in mind?


Offline grmorgan618

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Enhancement: Pre/Post Scripts
« Reply #6 on: January 21, 2019, 01:15:15 PM »
Awesome - yup that will work for me.

Offline Justin Chalfant

  • Patch My PC Support
  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
    • View Profile
    • Patch My PC Support
Re: Enhancement: Pre/Post Scripts
« Reply #7 on: January 21, 2019, 02:07:43 PM »
Cool, this build will most likely release sometime this week.

Offline Justin Chalfant

  • Patch My PC Support
  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
    • View Profile
    • Patch My PC Support
Re: Enhancement: Pre/Post Scripts
« Reply #8 on: February 11, 2019, 03:29:24 PM »
We will support script parameters in the next update.