runas 不允许复杂的参数? [英] runas does not allow complex arguments?
问题描述
我有一个应用程序,我试图在 Windows 7 和 Windows xp 瘦客户端上提升运行,但我似乎无法正确获取 runas.exe cmd 行.我知道我需要在那里使用反斜杠转义字符,以便 runas 正确解释空格.这在将 runas 发送为已用反斜杠转义的单个参数时有效.这种情况是我找到的所有解决方案,但它有效,但我需要发送多个参数,由于文件路径等原因,参数中的空格全部用反斜杠转义.以下是一些示例:
I have an app that I'm trying to run elevated on windows 7 and windows xp thin clients but I cant seem to get the runas.exe cmd line correct. I know I need the backslash escape character in there so runas interprets the spaces correctly. This works when sending runas a single argument that has been escaped with a backslash. This scenario is all I found as a solution and it works however, I need to send multiple arguments that are all escaped with backslashes because of spaces in the arguements due to file paths, etc. Here are some examples:
这些工作和预期一样会提示输入管理员密码:
These work And as expected will prompt for the administrator password:
runas.exe/user:Administrator "C:\update_andon.exe autosetup/kiosktype:\"Andon Kiosk"\
runas.exe/user:Administrator "C:\update_andon.exe autosetup/directory:\"C:\Program Files\CIMS_Andon\Kiosk"\
当我开始添加我需要的其余参数(如下行)时,我收到 runas 帮助文本,表明存在问题:
When I start adding the rest of the arguments I need such as the line below, I receive the runas help text indicating there was an issue:
runas.exe/user:administrator "C:\update_andon.exe autosetup/kiosktype:\"Andon Kiosk"\/exename:\"eAndonKiosk.exe"\/directory:\"C:\Program Files\CIMS_Andon\Kiosk"\/repository:\"\\domain\sat\shared\repository\andon kiosk"\"
一个解决方案是一个接一个地一次运行每个参数,但我不认为这是一种解决方案,而是一种解决方法.我将反斜杠与各种参数混合在一起的方式是否遗漏了什么?我是否在某处遗漏了更多引号?
One solution is to run each argument at a time one after the other but I dont see this as a solution as much as it is a workaround. Am I missing something with the way I have the backslashes mixed in with the various arguments? Am I missing more quotes somewhere?
谢谢
推荐答案
规范的解决方案:将命令写入批处理脚本并通过 runas
运行脚本.
Canonical solution: write the command to a batch script and run the script via runas
.
这篇关于runas 不允许复杂的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!