Passing parameter from Client CMD through ICA file to launch published Citrix App
Asked Answered
J

1

9

I'm trying to send a simple string parameter from C# web app code using CMD line call to ICA file to Citrix XenApp Server to launch a specific published application (Macro Scheduler macro compiled into exe), NOT the whole citrix desktop.

I have a web app with cmd line code using

"C:\Program Files (x86)\Citrix\ICA Client\Wfica32.exe"  C:\someICAfile.ica \Param:"/username=SomebodysName" .

I've also tried for the parameter syntax: /username=SomebodysName, /Param:"/username=SomebodysName"

and about a million other combinations of quotes and slashes.

I used Citrix QuickLaunch to write my ICA file, in which the only thing I changed was InitialProgram=#ApplicationName \Param (I added the \Param). I've also tried /username and \Param=SomebodysName and I can't get any of those to work either. I've even tried just hardcoding the name in there and I can't get it to go through.

The exe is expecting a parameter "username" and when called locally from the cmd prompt it works using UsernameProgram.exe /username=somebodysname. I made sure to include the "%*" at the end of the commandlineexecutable in the Citrix Xenapp application location properties to ensure that it can accept a command line parameter.

This is all using C# and XenApp 6. Everything works except passing the parameter through, and I have no idea where the parameter is lost, if it even gets anywhere. I feel like I have tried every combination of /'s \'s and "'s so if anybody could please help me out with the syntax, I'd really appreciate it! I did try looking into the ICA Client SDK in the c# code, but it seems to just manually do what an external ICA file will do. If this is wrong, however, please let me know. I'm approaching the point where I'm just going to try it regardless because I'm completely out of ideas. Please help.

Thanks!

Jonathonjonati answered 13/1, 2012 at 17:21 Comment(1)
to pass a static parameter from an ICA file to a published Citrix application: InitialProgram=#"ApplicationName""/faveColor=yellow" . In the application properties in Citrix Delivery Services Console, I changed the commandlineexecutable in the Location property to be C:\filePath\ApplicationName.exe "%**" . I believe the two *'s bypasses command line validation. Either way, this lets the parameter through to my app, as if I were calling the app from a command line locally. NOW i just need to figure out how to get the parameter into the ICA and all will be right again in the world.Jonathonjonati
J
6

I ended up calling a .bat file from my C# code by using the following:

Process proc_Launch = new Process();
proc_Launch.StartInfo.FileName = "CreateTempICA.bat";
proc_Launch.StartInfo.RedirectStandardError = false;
proc_Launch.StartInfo.RedirectStandardOutput = false;
proc_Launch.StartInfo.WorkingDirectory = @"C:\WorkingDirectory";
proc_Launch.StartInfo.Arguments = @"""/username=somebodysname""";
proc_Launch.Start();

reference: Run bat file in c# with .exe and .def code

In the .bat file, I create an ICA file passing in the username paramter as follows:

@echo off
:makefile
pushd %temp%
set icafile=temp.ica
@echo [WFClient] > %icafile%
@echo Version = 2 >> %icafile%
@echo HttpBrowserAddress=ServerName:8080 >> %icafile%
@echo ProxyType=Auto >> %icafile%
@echo ConnectionBar=0 >> %icafile%
@echo [ApplicationServers] >> %icafile%
@echo ApplicationName= >> %icafile%
@echo [ApplicationName] >> %icafile%
@echo Address = ApplicationName >> %icafile%
@echo InitialProgram=#"ApplicationName"%1 >> %icafile%
@echo ClientAudio=On >> %icafile%
@echo AudioBandwidthLimit=1 >> %icafile%
@echo CGPAddress=*:#### (use actual numbers here though) >> %icafile%
@echo CDMAllowed=On >> %icafile%
@echo CPMAllowed=On >> %icafile%
@echo DesiredColor=8 >> %icafile%
@echo ConnectionBar=0 >> %icafile%
@echo TWIMode=On >> %icafile%
@echo Compress=On >> %icafile%
@echo TransportDriver=TCP/IP >> %icafile%
@echo WinStationDriver=ICA 3.0 >> %icafile%
@echo BrowserProtocol=HTTPonTCP >> %icafile%
@echo [Compress] >> %icafile%
@echo DriverName= PDCOMP.DLL >> %icafile%
@echo DriverNameWin16= PDCOMPW.DLL >> %icafile%
@echo DriverNameWin32= PDCOMPN.DLL >> %icafile%
start %icafile%
popd

The %1 in the InitialProgram component is where the argument is used from the C# code.

reference: http://www.virtualizationadmin.com/files/whitepapers/MetaframeXP/Connecting_to_a_Citrix_server_from_the_command_line.htm

The last step is to make sure in your Citrix Delivery Console to make sure that the Location properties of the published application for the CommandLineExecutable has a "%**" after it, including the double quotes. I believe adding the 2nd asterisk lets the parameter get through the command line validation and allows it to be used when the application is opened. Either way though, it worked with two of them and not with one of them.

Jonathonjonati answered 17/1, 2012 at 20:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.