Quellcode durchsuchen

python -W ignore -u file 命令行,当文件存在空格时,需要为file加双引号,注意:单引号无效

scbc.sat2 vor 5 Jahren
Ursprung
Commit
29366919f9
1 geänderte Dateien mit 4 neuen und 4 gelöschten Zeilen
  1. 4 4
      SATService/SATService/PythonExecutor.cpp

+ 4 - 4
SATService/SATService/PythonExecutor.cpp

@@ -170,9 +170,9 @@ int CPythonExecutor::RunScriptProcess()
 	// 强制stdion, stdout和stderr完全无缓冲:python -u
 	TCHAR szCommandLine[MAX_PATH] = { 0 };
 	if (_tcslen(m_szExtraSentence))
-		_stprintf_s(szCommandLine, _T("python -W ignore -u %s %s"), m_szScriptPath, m_szExtraSentence);
+		_stprintf_s(szCommandLine, _T("python -W ignore -u \"%s\" %s"), m_szScriptPath, m_szExtraSentence);
 	else
-		_stprintf_s(szCommandLine, _T("python -W ignore -u %s"), m_szScriptPath);
+		_stprintf_s(szCommandLine, _T("python -W ignore -u \"%s\""), m_szScriptPath);
 
 	// 重定向输出;
 	RedirectSubprocessStdout(&m_si);
@@ -321,9 +321,9 @@ int CPythonExecutor::ServiceRunScriptProcess()
 	// 强制stdion, stdout和stderr完全无缓冲:python -u
 	TCHAR szCommandLine[MAX_PATH] = { 0 };
 	if (_tcslen(m_szExtraSentence))
-		_stprintf_s(szCommandLine, _T("python -W ignore -u %s %s"), m_szScriptPath, m_szExtraSentence);
+		_stprintf_s(szCommandLine, _T("python -W ignore -u \"%s\" %s"), m_szScriptPath, m_szExtraSentence);
 	else
-		_stprintf_s(szCommandLine, _T("python -W ignore -u %s"), m_szScriptPath);
+		_stprintf_s(szCommandLine, _T("python -W ignore -u \"%s\""), m_szScriptPath);
 
 	bResult = CreateProcessAsUser(
 		hUserTokenDup,                     // client's access token