-
안녕하세요.
qt를 이용해서 코딩중에 궁금한 내용이 있어 문의드립니다.
경로 : C:\Windows\System32\cmd.exe
ShellExecute 를 이용해서 명령프롬포트 창을 실행하려고 합니다.
경로에서 직접 실행 시 명령프롬포트 창이 팝업되고 scp 명령이 유효합니다.그런데 코드로 cmd 창을 실행하면 scp 명령이 유효하지 않고 cmd 창 색도 다릅니다.
ShellExecute(NULL, TEXT("open"), TEXT("cmd.exe"), TEXT("/c scp"), NULL, SW_SHOW);코드로 scp 명령을 수행해야 하는데 해결 방법이 있을까요?
ps) qprocess로 실행 시 scp 명령이 유효하지 않는 것 같습니다. -
I can only see what Google Translate shows me.
ShellExecute() is a Windows API function and nothing to do with Qt or QProcess.
If you want help with QProcess you should post the code you are trying to use.
Google Translate:
I would like to contact you if I have any questions while coding using QT. Path: C:\Windows\System32\cmd.exe I am trying to run a command prompt window using ShellExecute. When running directly from the path, a command prompt window pops up and the scp command is valid. But when I run the cmd window with the code, the scp command is not valid and the cmd window color is also different. ShellExecute(NULL, TEXT("open"), TEXT("cmd.exe"), TEXT("/c scp"), NULL, SW_SHOW); I need to execute the scp command in code. Is there a solution? ps) The scp command seems to be invalid when run with qprocess.
-
-
@hlowd You use ShellExecute when you have a file and want to launch the associated application, e.g. Open whatever is configured to handle PNG files by giving ShellExecute the PNG file. If you want to use a Windows API call to launch an executable then you should be looking at CreateProcess or a related function.
-
@hlowd said in ShellExecute 사용 관련 문의:
코드로 scp 명령을 수행해야 하는데 해결 방법이 있을까요?
ps) qprocess로 실행 시 scp 명령이 유효하지 않는 것 같습니다.I need to run the scp command with the code, is there any workaround?
P.S. The scp command doesn't seem to be valid when executed with qprocess.(translated with DeepL)
If you want to start a
QProcess
and runscp
do something like this:QProcess process; // Path to your scp, wherever it is... // e.g. C:/Windows/System32/OpenSSH/scp.exe QString command = "C:/Program Files/Git/usr/bin/scp.exe"; // you need full path to scp.exe here // or register in PATH variable on your system so that Windows knows the "scp" command and where the program is located QStringList params; params.append("/C/Path/to/File"); params.append("user@host:/C/Destination/Path/"); process.start(command, params, QIODevice::ReadWrite);
-