由于报价,Runas CMD无法正常工作

时间:2019-01-03 13:35:35

标签: batch-file cmd runas

我在批处理文件中使用此行:

//constructor makes a student object and initialises the map; marks.
Student::Student(const string &name, int regNo) : Person(name) {
    this->name = name;
    this->regNo = regNo;
    // map<string, float> marks; // this line is not needed. 
}

问题在于,这仅在文件的路径没有空格的情况下有效。而且我不能像通常那样将路径放在引号中,因为整个CMD命令必须在引号中。

Runas /user:domain\user "cmd /C echo Test > C:\Program Files\Install2AgentService\Install2AgentWinService.exe.config"

即使转义双引号也不起作用。

Runas /user:domain\user "cmd /C echo Test > "C:\Program Files\Install2AgentService\Install2AgentWinService.exe.config""

有人知道如何处理该问题吗?谢谢!

1 个答案:

答案 0 :(得分:1)

使用Account.IndexOf indexOf = new Account.IndexOf(); int index; if ((index = AccountList.FindIndex(indexOf.Match("john"))) > 0) { // do something with John } if ((index = AccountList.FindIndex(indexOf.Match("jane"))) > 0) { // do something with Jane } 反固相线(反斜杠)转义内部双引号,如下所示:

\

资源(等效):

  • Runas /user:domain\user "cmd /C echo Test>\"C:\Program Files\Install2AgentService\Install2AgentWinService.exe.config\"" 从打开的命令提示符下
  • RUNAS at ss64.com

用例示例

runas /?