Giter Club home page Giter Club logo

Comments (14)

adamdriscoll avatar adamdriscoll commented on July 17, 2024 2

I was able to achieve this with a batch script.

Protocol handler command line

C:\ProgramData\BurntToast\BurntToast.cmd %1

BurntToast.cmd

powershell.exe -WindowStyle hidden -NonInteractive -ExecutionPolicy Bypass -NoLogo -NoProfile  -Command "& '%1'.Replace('powershell://', '').Trim('/')"

from burnttoast.

jholl016 avatar jholl016 commented on July 17, 2024 1

Creating a custom URI to launch a specific program does work. However, I found it cumbersome to create unique URI's for every unique action that I might like to call from a BT button.

For a generalized solution, I created a single custom URI that points to a locally staged instance of the PowerShell App Deployment Toolkit. Then I use the toolkit script to process the argument string that launched the protocol and take the necessary action. The way I designed my script, it can execute either an EXE or a PS1, with optional parameters in both cases.

With this, now I have a single setup routine to run on each client PC which does the following:

  • Install BurntToast Module
  • Install custom AppID MSI
  • Configure the single custom URI
  • Stage the PS App Deploy Toolkit instance

And I can now launch any EXE or PS1 with parameters going forward without any other URIs to configure. I can whip out new notifications to my users with fully customized actions in no time now!

Note: If you're comfortable developing in Visual Studio, you could probably create a dedicated command line app to do the same thing, instead of using PSADT. I'm just far more comfortable with PowerShell.

from burnttoast.

ibrahimsharif avatar ibrahimsharif commented on July 17, 2024

Could you try to pass this line as arguments

runas.exe /savecred /user:Domain\User " cmd /c start "C:\Users\iba\Desktop\yourEXEfilegoeshere.exe"

ActivationType Protocol Uses Windows Uri Scehma i think you could make you own entry

https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

from burnttoast.

jamesreedflinders avatar jamesreedflinders commented on July 17, 2024

Thanks ibrahimsharif,

I wasn't able to get the above argument working, however, I did come across the 'Create your own URI' post when I originally tested this. I created a custom URI to launch the required app and it works fine.

One of the scenarios we wanted to address was launch SCCM software centre, thankfully Microsoft already create a URI for this so we replace one of the arguments with $argument2 = 'softwarecenter://'

We took the information from the software center URI and created our own custom one.

from burnttoast.

chandan169 avatar chandan169 commented on July 17, 2024

jholl016

Creating a custom URI to launch a specific program does work. However, I found it cumbersome to create unique URI's for every unique action that I might like to call from a BT button.

For a generalized solution, I created a single custom URI that points to a locally staged instance of the PowerShell App Deployment Toolkit. Then I use the toolkit script to process the argument string that launched the protocol and take the necessary action. The way I designed my script, it can execute either an EXE or a PS1, with optional parameters in both cases.

With this, now I have a single setup routine to run on each client PC which does the following:

  • Install BurntToast Module
  • Install custom AppID MSI
  • Configure the single custom URI
  • Stage the PS App Deploy Toolkit instance

And I can now launch any EXE or PS1 with parameters going forward without any other URIs to configure. I can whip out new notifications to my users with fully customized actions in no time now!

Note: If you're comfortable developing in Visual Studio, you could probably create a dedicated command line app to do the same thing, instead of using PSADT. I'm just far more comfortable with PowerShell.

Can you please share how can i call powershell script. I have register powershell.exe on registry.
Computer\HKEY_CLASSES_ROOT\Powershell\shell\open\command
powershell.exe "%1"

from burnttoast.

rishi-dhar avatar rishi-dhar commented on July 17, 2024

Creating a custom URI to launch a specific program does work. However, I found it cumbersome to create unique URI's for every unique action that I might like to call from a BT button.

For a generalized solution, I created a single custom URI that points to a locally staged instance of the PowerShell App Deployment Toolkit. Then I use the toolkit script to process the argument string that launched the protocol and take the necessary action. The way I designed my script, it can execute either an EXE or a PS1, with optional parameters in both cases.

With this, now I have a single setup routine to run on each client PC which does the following:

  • Install BurntToast Module
  • Install custom AppID MSI
  • Configure the single custom URI
  • Stage the PS App Deploy Toolkit instance

And I can now launch any EXE or PS1 with parameters going forward without any other URIs to configure. I can whip out new notifications to my users with fully customized actions in no time now!

Note: If you're comfortable developing in Visual Studio, you could probably create a dedicated command line app to do the same thing, instead of using PSADT. I'm just far more comfortable with PowerShell.

Can you elaborate how you did this in PowerShell? I tried setting up a custom URI in registry - it's working everywhere else except when clicking the Toast Notification button.

from burnttoast.

martinisoft1 avatar martinisoft1 commented on July 17, 2024

Can you elaborate how you did this in PowerShell? I tried setting up a custom URI in registry - it's working everywhere else except when clicking the Toast Notification button. <

The same goes for me, doe you have some information on how you got this working?

from burnttoast.

zebulun78 avatar zebulun78 commented on July 17, 2024

Creating a custom URI to launch a specific program does work. However, I found it cumbersome to create unique URI's for every unique action that I might like to call from a BT button.

For a generalized solution, I created a single custom URI that points to a locally staged instance of the PowerShell App Deployment Toolkit. Then I use the toolkit script to process the argument string that launched the protocol and take the necessary action. The way I designed my script, it can execute either an EXE or a PS1, with optional parameters in both cases.

With this, now I have a single setup routine to run on each client PC which does the following:

* Install BurntToast Module

* Install custom AppID MSI

* Configure the single custom URI

* Stage the PS App Deploy Toolkit instance

And I can now launch any EXE or PS1 with parameters going forward without any other URIs to configure. I can whip out new notifications to my users with fully customized actions in no time now!

Note: If you're comfortable developing in Visual Studio, you could probably create a dedicated command line app to do the same thing, instead of using PSADT. I'm just far more comfortable with PowerShell.

Could you share how you created your custom URI and how you are passing that in the arguments? I have also done everything you have listed here, and the URI works if launched in IE or other local methods, but NOT from this toast message. Arggg....

from burnttoast.

jholl016 avatar jholl016 commented on July 17, 2024

I didn't do anything special for the URI protocol handler. Refer to this documentation: https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

As for how I pass all the necessary information to the handler script, I do that by writing all the info to a formatted temp file (like xml or json). Then I pass that info file to the custom protocol, like custom protocol://path/to/my/settingsFile.xml.

Then my handler script reads the xml and executes the action with whatever parameters were specified.

from burnttoast.

jholl016 avatar jholl016 commented on July 17, 2024

One thought... Toast actions have a couple of different supported types. Make sure you're using the protocol action type.

from burnttoast.

rishabhnag1 avatar rishabhnag1 commented on July 17, 2024

Can you elaborate how you did this in PowerShell? I tried setting up a custom URI in registry - it's working everywhere else except when clicking the Toast Notification button. <

The same goes for me, doe you have some information on how you got this working?

@martinisoft1 @bbadger86 Did either of you figure out how to run a powershell script through the button action? I have the URI command working fine everywhere other than the notification as well! Configured my URI command as follows
powershell.exe -executionpolicy unrestricted -file <filename.ps1>

from burnttoast.

jholl016 avatar jholl016 commented on July 17, 2024

@rishabhnag1 Your PowerShell launch string does not constitute a valid URI. Please review the link in my comment above to familiarize yourself with URI creation and formatting. In short, there is no way for you to call a PowerShell script directly from the toast. You have to create a handler app with a published URI protocol and pass your script to that handler.

from burnttoast.

Windos avatar Windos commented on July 17, 2024

I demo'ed this at RTPSUG last week (video will be out at some stage, and code is on it's way to their repo)

I was pointing it at a .ps1 file from the .cmd and trimming the protocol out of the string from inside the script... but I like your way better @adamdriscoll

If people want this packaged up with a helper or two inside the BurntToast module, I can do that. Otherwise I plan on documenting the crap out of it.

from burnttoast.

Windos avatar Windos commented on July 17, 2024

In addition to protocol handlers, it's now possible to run any code via a toast notification action. This does require PowerShell 7.1 or above and BurntToast 0.8.0.

This blog post shows it in action, though with v0.8.0 it's a lot easier to take advantage of this via some new parameters on New-BurntToastNotification and Submit-BTNotification. Documentation for this is coming soon, for now check out the end of this live stream.

from burnttoast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.