我最终使用以下命令从我的 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();
参考:使用 .exe 和 .def 代码在 c# 中运行 bat 文件
在 .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
InitialProgram 组件中的 %1 是在 C# 代码中使用参数的位置。
参考: http: //www.virtualizationadmin.com/files/whitepapers/MetaframeXP/Connecting_to_a_Citrix_server_from_the_command_line.htm
最后一步是确保在您的 Citrix Delivery Console 中确保 CommandLineExecutable 的已发布应用程序的位置属性后面有一个“%**”,包括双引号。我相信添加第二个星号可以让参数通过命令行验证并允许在打开应用程序时使用它。不管怎样,它与其中两个一起工作,而不是与其中一个一起工作。