Jump to content
Welcome to our new Citrix community!
  • 0

Powershell Called by Published App to Identify Which App Called it

Mike Winspear


Good Morning All,


I've got a challenge and hoping someone might be able to help / advise with this.


Currently I have a Powershell Script that I can run as a Published application in 7.15, this works fine. The purpose of this scripts is setting default printers ahead of the application launch, so at the end of the script it calls the executable fore the application that the user actually wants to run..... all working absolutely fine as I want it.... 


however....... now the business unit im working with wants to run the same powershell script in front of 5 other applications, what I really dont want to do is to write 5 different scripts with each one of them calling a different executable at the end of running the Printer default bits of the script, dont want to because I fear this could get messy particularly as they install more and more applications. What I would like to do is to have one script to "rule", so that the main part of the script does the same with calling printers, setting the default etc, but Depending on what Published application was run then run the corresponding executable.


So for Instance...


User Clicks to Run Published application........    "Dragons"

The published application set to run is "GenericPS.PS1"

GenericPS.PS1 runs happily in the back ground looking for the users session printers, setting one as default, writing that to the registry etc, then looks at what published app was run ("Dragons") and finds the line "Dragons" (or an IF statement so IF Name=Dragons goto Dragons) in the Powershell script which calls the program executable for Dragons.


Hope this makes some sense



Link to comment

2 answers to this question

Recommended Posts

  • 0

Thanks for the response, came up with a middle of the road approach instead, have added a command line parameter to the published application call and created the parameters in the Powershell to load an executable based on the "WORD" in the command line, works a treat.




The Published App Command Line for "Dragons application" now has..


-windowstyle hidden -ExecutionPolicy RemoteSigned -Command & %SystemDrive%\SSC\Scriptname.ps1 "dragons"


The Published App Command Line for "Witches application" now has..


-windowstyle hidden -ExecutionPolicy RemoteSigned -Command & %SystemDrive%\SSC\Scriptname.ps1 "witches"


and in the Powershell after all the print stuff is done I have...


#Use Parameter to choose app to load
switch ($app)
    "dragons" { Start-Process -FilePath "D:\Program Files\dragons\dragons.exe"}

    "witches" { Start-Process -FilePath "D:\Program Files\witches\witches.exe"}




Works Perfectly.


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...