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

Xenapp 7.15 on Win 2016 Script for Default Printer - Problems

Mike Winspear


Hi All,


Through some very helpful advise on here and a Script by Wendell in this thread https://discussions.citrix.com/topic/396513-windows-server-2016-and-xenapp-715-cu2-default-printer-registry-key-not-set-when-launching-published-app/?source=email


I was able to hash together my own script, there were some intricacies because the Published application is a Launcher that launches a Menu command file for users to select the apps they want, anyway I managed it eventually, however I need a little assistance in tidying it up a bit, Script I have is below


Add-PSSnapin Citrix*

Get-BrokerMachine -adminaddress "DCName.mysomain.local" | select HostedMachineName,WindowsConnectionSetting,SummaryState,SessionsEstablished


       The Above lines I've used in order to load the snapins on the App Servers, this is where the launcher runs from and the launcher being a simple batch file with a bunch of menu options that then calls the EXE's on the app server, I know I could get the app server to use the snapins from the remote Delivery Controller, but decided to go down this route instead, however, I really don't want the output the I get with the Get-BrokerMachine Line, if I remove the select then I'll just get a scroll through of all apps on the remote controller, I just want to be able to have the app server know that the Delivery Controller is a remote machine and that is where it has to call the published application from to be able to set the WaitForPrinterCreation against.


Set-BrokerApplication GER\Test\"Launcher Test" -WaitForPrinterCreation:1

# Clear any existing errors.
"Waiting for printers to be created"

Start-Sleep 5

$registrykey = "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows"

# Set the location
Set-Location -Path $registrykey -ErrorAction SilentlyContinue

# Retrieve the default printer properties.
$wmiDefaultPrinter = Get-WmiObject -query "SELECT * FROM WIN32_PRINTER WHERE Default = TRUE"

# If the default printer exists then set the registry values.
if ($wmiDefaultPrinter -ne $null)
    "Setting the Windows default printer registry key"
    Set-ItemProperty -Path $registrykey -Name "Device" -Value ($wmiDefaultPrinter.Name+",winspool,Ne00:")
    Write-Host "Your default printer is" $wmiDefaultPrinter.Name
} else {
    Set-ItemProperty -Path $registrykey -Name "Device" -Value "Microsoft Print to PDF,winspool,Ne01:"
Start-Process -FilePath "D:\Program Files\Omnis Software\OS8.1.6RT\omnis.exe" D:\PMS_Libraries\PMS_V8\global.lbs


The Application executable has to be able to call the application library file as it does in the above, this works fine, however once the application has loaded, i need the launcher menu that was triggered in the first place, to remain open and allow users to select other options from the menu, however what does happen at the moment is it just sits at the end of the PS script showing in the window in the background with all the junk that was produced from the Get-BrokerMachine line.


Summary of how the user sees things...


They Have a Published App called Launcher, they Run this which starts in a Citrix Session

Launchers has 5 Application Choices called from a  .bat file, if they select 1 from the menu, this starts the PMS application that the above was written for, that option on the menu, in the .bat file calls the .PS1 file with the powershell above in.

The Powershell runs but can be seen in the same window as the menu options were but doesnt return to the original menu options.


Any Help would be very well received.



Link to comment

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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