QProcess从活动cmd会话运行ssh

时间:2019-02-12 11:20:53

标签: c++ qt

QProcess m_prc_ssh;

m_prc_ssh.setProgram("cmd");
m_prc_ssh.start();
m_prc_ssh.write("chcp 1251\r\n");

connect(&m_prc_ssh, &QProcess::readyRead, this, &Tab_Server::on_ssh_output);

...

m_prc_ssh.write("c:\\Windows\\System32\\OpenSSH\\ssh.exe\r\n");

...

void Tab_Server::on_ssh_output()
{
    m_edt_ssh_output->setText(m_edt_ssh_output->toPlainText() += "> " + QString::fromLocal8Bit(m_prc_ssh.readAll()) + "\r\n");
    m_edt_ssh_output->setText(m_edt_ssh_output->toPlainText() += "> " + QString::fromLocal8Bit(m_prc_ssh.readAllStandardOutput()) + "\r\n");
    m_edt_ssh_output->setText(m_edt_ssh_output->toPlainText() += "> " + QString::fromLocal8Bit(m_prc_ssh.readAllStandardError()) + "\r\n");
}

这是问题。
文件存在时,cmd看不到c:\ Windows \ System32 \ OpenSSH \ ssh.exe。
每次错误“系统找不到指定的路径。”
我可以启动calc.exe进程或其他进程(word,totalcmd或其他所有进程),但不能启动ssh ...这是怎么回事?

UPD: 在管理员特权下运行时,qt进程似乎无法访问openssh文件夹
还回显%PATH%输出:

G:\Stereolife\SDK\Qt\5.9.0\static\\bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\0jal225p.zmb\lib\win32\x86;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\NativeBinaries\x86;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\mpirt;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\mpirt;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files\Oculus\Support\oculus-runtime;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Users\golds\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\golds\AppData\Local\Programs\Python\Python37-32\;C:\Users\golds\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft Visual Studio 14.0\;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

0 个答案:

没有答案