简体   繁体   English

通过ICA文件从Client CMD传递参数以启动已发布的Citrix App

[英]Passing parameter from Client CMD through ICA file to launch published Citrix App

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. 我正在尝试使用CMA线路调用从C#web应用程序代码向Citrix XenApp Server发送一个简单的字符串参数,以启动特定的已发布应用程序(编译为exe的宏调度程序宏),而不是整个Citrix桌面。

I have a web app with cmd line code using 我有一个使用cmd行代码的Web应用程序

"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" 我也试过参数语法: /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). 我使用Citrix QuickLaunch来编写我的ICA文件,其中我唯一改变的是InitialProgram=#ApplicationName \\Param (我添加了\\ Param)。 I've also tried /username and \\Param=SomebodysName and I can't get any of those to work either. 我也尝试过/username\\Param=SomebodysName ,我也无法使用其中任何一个。 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 . exe期望参数“ username ”,当从cmd提示符本地调用时,它使用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. 我确保在Citrix Xenapp应用程序位置属性中的commandlineexecutable末尾包含“ %* ”,以确保它可以接受命令行参数。

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. 这都是使用C#和XenApp 6.一切正常,除了传递参数,我不知道参数丢失的位置,如果它甚至可以到达任何地方。 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. 我觉得我已经尝试了/和s的所有组合,所以如果有人能帮我解决语法问题,我真的很感激!我确实试过在c#中查看ICA Client SDK代码,但它似乎只是手动执行外部ICA文件将执行的操作。但是,如果这是错误的,请告诉我。我正在接近我将要尝试它的点,因为我完全没有想法。请帮忙。

Thanks! 谢谢!

I ended up calling a .bat file from my C# code by using the following: 我最终通过使用以下内容从我的C#代码调用.bat文件:

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 reference: 使用.exe和.def代码在c#中运行bat文件

In the .bat file, I create an ICA file passing in the username paramter as follows: 在.bat文件中,我创建了一个传递用户名参数的ICA文件,如下所示:

@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. InitialProgram组件中的%1是从C#代码中使用参数的位置。

reference: http://www.virtualizationadmin.com/files/whitepapers/MetaframeXP/Connecting_to_a_Citrix_server_from_the_command_line.htm 参考: 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. 最后一步是确保在Citrix Delivery Console中确保CommandLineExecutable的已发布应用程序的位置属性后面包含“%**”,包括双引号。 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. 无论哪种方式,它与其中两个一起工作而不是其中一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM