You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在RDP文件的alternate shell中为EXE程序传递参数

Passing Arguments to a Custom .NET App via RDP File

Great question! I’ve dealt with this exact issue before—while the official RDP specs don’t explicitly cover passing arguments to an alternate shell, there are two reliable workarounds that get the job done.

Workaround 1: Use cmd.exe to Wrap Your Program Call

Instead of pointing alternate shell directly to your .NET app, use Windows Command Prompt to execute the app with its arguments. This works because cmd.exe handles argument parsing correctly for the target program.

Update your RDP file’s alternate shell line to look like this:

alternate shell:s:cmd.exe /c "C:\MPT\Program.exe your-first-argument your-second-argument"
  • The /c flag tells cmd.exe to run the command and then exit (so you don’t get a lingering command prompt window).
  • If your program path or arguments contain spaces, wrap the entire app call in quotes as shown.

Workaround 2: Use a Batch File for More Control

If you need to add extra logic (like checking for dependencies before launching) or want to keep your RDP file clean, create a batch file on the remote machine that handles launching your app with arguments.

  1. On the remote machine, create a file named StartProgram.bat in C:\MPT\ with this content:
@echo off
REM Replace with your actual arguments
C:\MPT\Program.exe argument1 "argument with spaces"
  1. Update your RDP file’s alternate shell line to point to the batch file:
alternate shell:s:C:\MPT\StartProgram.bat

Key Notes

  • Make sure the remote user account has read/execute permissions for both your .NET app and any batch files/cmd.exe.
  • If your app requires the remote desktop session to stay active after launching, avoid using /c (use /k instead for cmd.exe), but this will leave a command prompt open—most of the time, /c is the better choice for headless app launches.
  • Test the command/batch file manually on the remote machine first to ensure it runs your app with the correct arguments before adding it to the RDP file.

Both of these methods have worked consistently for me when deploying .NET apps via RDP. Let me know if you run into any snags!

内容的提问来源于stack exchange,提问作者vifelisberto

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 08:47:34