|
@@ -14,7 +14,7 @@
|
|
|
|
|
|
CCmd::CCmd()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
BOOL CCmd::Installcmd()
|
|
@@ -52,7 +52,7 @@ BOOL CCmd::InstallNetcmd()
|
|
|
if (systemLetter == L"")
|
|
|
{
|
|
|
systemLetter = L"C";
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//安装NET Framework工具所在路径是固定的
|
|
@@ -67,106 +67,122 @@ BOOL CCmd::InstallNetcmd()
|
|
|
|
|
|
std::wstring cmd = L"";
|
|
|
//cmd = L"dism /online /enable-feature /featurename:IIS-ASPNET45 /all";//win8需要启动ASPNET4.5服务,目前暂时没用到;
|
|
|
-
|
|
|
+
|
|
|
//检测当前系统为win8或更高版本
|
|
|
if (IsWindows8OrGreater())
|
|
|
{
|
|
|
cmd = L"/k " + systemLetter + L": & cd " + netframe + L" & aspnet_regiis.exe -i /qb /qn";
|
|
|
-
|
|
|
- std::map<wstring, wstring> map{ {L"InstallNetFramwork", cmd}, { L"WindowsVersion", L"Win8,10.."}};
|
|
|
+
|
|
|
+ std::map<wstring, wstring> map{ {L"InstallNetFramwork", cmd}, { L"WindowsVersion", L"Win8,10.." }};
|
|
|
LogIni::GetLogToIniMaps(map);
|
|
|
m_IsWin8InstallNet = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
cmd = L"/k " + systemLetter + L": & cd " + netframe + L" & aspnet_regiis.exe -i /qb /qn";
|
|
|
-
|
|
|
- std::map<wstring, wstring> map{ {L"InstallNetFramwork", cmd}, { L"WindowsVersion", L"Win7"} };
|
|
|
+
|
|
|
+ std::map<wstring, wstring> map{ {L"InstallNetFramwork", cmd}, { L"WindowsVersion", L"Win7" } };
|
|
|
LogIni::GetLogToIniMaps(map);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
TCHAR* tc = (TCHAR*)(&cmd[0]);
|
|
|
return Executecmd(tc);
|
|
|
}
|
|
|
|
|
|
+BOOL CCmd::InstallVcPlusPluscmd() {
|
|
|
+ std::wstring cmd = L"";
|
|
|
+ wchar_t downloadsPath[MAX_PATH];
|
|
|
+ DWORD bufferSize = ::GetEnvironmentVariable(L"USERPROFILE", downloadsPath, MAX_PATH);
|
|
|
+ std::wstring wstrPath_Install(downloadsPath);
|
|
|
+ wstrPath_Install += L"\\Downloads";
|
|
|
+ //防止目标路径与当前进程所在盘符不一致,所以在cd之前,要指定目标路径的盘符cdDisk
|
|
|
+ auto cdDisk = wstrPath_Install.substr(0, 1) + L": & ";
|
|
|
+ cmd = L"/k " + cdDisk + L"cd \"" + wstrPath_Install + L"\"" + L" & curl -o vc_redist.x64.exe https://download.visualstudio.microsoft.com/download/pr/eaab1f82-787d-4fd7-8c73-f782341a0c63/917C37D816488545B70AFFD77D6E486E4DD27E2ECE63F6BBAAF486B178B2B888/VC_redist.x64.exe && start /wait vc_redist.x64.exe /install /quiet /norestart && del vc_redist.x64.exe";
|
|
|
+
|
|
|
+ //LogIni::GetLogToIni("Install cmd", cmd);
|
|
|
+ TCHAR* tc = (TCHAR*)(&cmd[0]);
|
|
|
+ return Executecmd(tc);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
BOOL CCmd::OpenAppcmd()
|
|
|
{
|
|
|
//Todo:目前不使用该函数
|
|
|
std::wstring cmd = L"";
|
|
|
|
|
|
- auto cdDisk = PathCore::smPath_Install.substr(0, 1) + L": & ";
|
|
|
+ auto cdDisk = PathCore::smPath_Install.substr(0, 1) + L": & ";
|
|
|
|
|
|
- cmd = L"/k " + cdDisk + L"cd \"" + PathCore::smPath_Install + L"\"" + L" & start/wait " + Product::smName_Application;
|
|
|
+ cmd = L"/k " + cdDisk + L"cd \"" + PathCore::smPath_Install + L"\"" + L" & start/wait " + Product::smName_Application;
|
|
|
|
|
|
- LogIni::GetLogToIni("Start App cmd", cmd);
|
|
|
+ LogIni::GetLogToIni("Start App cmd", cmd);
|
|
|
TCHAR* tc = (TCHAR*)(&cmd[0]);
|
|
|
- return Executecmd(tc);
|
|
|
+ return Executecmd(tc);
|
|
|
}
|
|
|
|
|
|
-BOOL CCmd::Executecmd(TCHAR pszCmdLine[],bool isVBA)
|
|
|
+BOOL CCmd::Executecmd(TCHAR pszCmdLine[], bool isVBA)
|
|
|
{
|
|
|
- char Buffer[4096];
|
|
|
- STARTUPINFO sInfo;//新进程的主窗口特性
|
|
|
- PROCESS_INFORMATION pInfo;
|
|
|
- SECURITY_ATTRIBUTES sa;
|
|
|
- HANDLE hRead, hWrite;
|
|
|
- DWORD bytesRead; //读取代码的长度
|
|
|
- sa.nLength = sizeof(SECURITY_ATTRIBUTES); //结构体的大小,可用SIZEOF取得
|
|
|
- sa.lpSecurityDescriptor = NULL;//安全描述符
|
|
|
- sa.bInheritHandle = TRUE;; //安全描述的对象能否被新创建ÆÆ的进程继承
|
|
|
-
|
|
|
- if (!CreatePipe(&hRead, &hWrite, &sa, 0))
|
|
|
- {
|
|
|
- return GetLastError();
|
|
|
- }
|
|
|
+ char Buffer[4096];
|
|
|
+ STARTUPINFO sInfo;//新进程的主窗口特性
|
|
|
+ PROCESS_INFORMATION pInfo;
|
|
|
+ SECURITY_ATTRIBUTES sa;
|
|
|
+ HANDLE hRead, hWrite;
|
|
|
+ DWORD bytesRead; //读取代码的长度
|
|
|
+ sa.nLength = sizeof(SECURITY_ATTRIBUTES); //结构体的大小,可用SIZEOF取得
|
|
|
+ sa.lpSecurityDescriptor = NULL;//安全描述符
|
|
|
+ sa.bInheritHandle = TRUE;; //安全描述的对象能否被新创建ÆÆ的进程继承
|
|
|
+
|
|
|
+ if (!CreatePipe(&hRead, &hWrite, &sa, 0))
|
|
|
+ {
|
|
|
+ return GetLastError();
|
|
|
+ }
|
|
|
+
|
|
|
+ GetStartupInfo(&sInfo);
|
|
|
+ sInfo.cb = sizeof(sInfo);
|
|
|
+ sInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
|
|
+ sInfo.wShowWindow = SW_HIDE;
|
|
|
+ sInfo.hStdError = hWrite; //将管道的写端交给子进程
|
|
|
+ sInfo.hStdOutput = hWrite;
|
|
|
+ memset(&pInfo, 0, sizeof(pInfo));
|
|
|
+ wstring cmdPath = L"";
|
|
|
+ if (isVBA == false)
|
|
|
+ {
|
|
|
+ cmdPath = L"c:\\windows\\system32\\cmd.exe";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wstring Installpath = PathCore::smPath_Install + L"\\install.bat";
|
|
|
+ cmdPath = Installpath;
|
|
|
+ }
|
|
|
+ if (!CreateProcessW(cmdPath.c_str(), pszCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &sInfo, &pInfo))
|
|
|
+ {
|
|
|
+ CloseHandle(hWrite);
|
|
|
+ CloseHandle(hRead);
|
|
|
+ return GetLastError();
|
|
|
+ }
|
|
|
|
|
|
- GetStartupInfo(&sInfo);
|
|
|
- sInfo.cb = sizeof(sInfo);
|
|
|
- sInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
|
|
- sInfo.wShowWindow = SW_HIDE;
|
|
|
- sInfo.hStdError = hWrite; //将管道的写端交给子进程
|
|
|
- sInfo.hStdOutput = hWrite;
|
|
|
- memset(&pInfo, 0, sizeof(pInfo));
|
|
|
- wstring cmdPath = L"";
|
|
|
- if(isVBA == false)
|
|
|
+
|
|
|
+ for (int i = 0;; ++i)
|
|
|
+ {
|
|
|
+ //执行cmd结束之后,则读取文件结束
|
|
|
+ if (!ReadFile(hRead, Buffer, sizeof(Buffer) - 1, &bytesRead, NULL))
|
|
|
{
|
|
|
- cmdPath = L"c:\\windows\\system32\\cmd.exe";
|
|
|
+ break;
|
|
|
+ Buffer[bytesRead] = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- wstring Installpath = PathCore::smPath_Install + L"\\install.bat";
|
|
|
- cmdPath = Installpath;
|
|
|
- }
|
|
|
- if (!CreateProcessW(cmdPath.c_str(), pszCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &sInfo, &pInfo))
|
|
|
- {
|
|
|
+ WaitForSingleObject(pInfo.hProcess, 1000);
|
|
|
CloseHandle(hWrite);
|
|
|
CloseHandle(hRead);
|
|
|
- return GetLastError();
|
|
|
+ return TRUE;
|
|
|
}
|
|
|
|
|
|
|
|
|
- for (int i = 0;; ++i)
|
|
|
- {
|
|
|
- //执行cmd结束之后,则读取文件结束
|
|
|
- if (!ReadFile(hRead, Buffer, sizeof(Buffer) - 1, &bytesRead, NULL))
|
|
|
- {
|
|
|
- break;
|
|
|
- Buffer[bytesRead] = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- WaitForSingleObject(pInfo.hProcess, 1000);
|
|
|
- CloseHandle(hWrite);
|
|
|
- CloseHandle(hRead);
|
|
|
- return TRUE;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- CloseHandle(hWrite);
|
|
|
- CloseHandle(hRead);
|
|
|
- return TRUE;
|
|
|
+ CloseHandle(hWrite);
|
|
|
+ CloseHandle(hRead);
|
|
|
+ return TRUE;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -177,7 +193,7 @@ BOOL CCmd::Executecmd(TCHAR pszCmdLine[],bool isVBA)
|
|
|
//因时间有限,暂时不进行排查修复UTF-16的vba脚本执行没反应的问题
|
|
|
bool CCmd::GetVBA_UTF16()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
std::wstring cmdd = L"";
|
|
|
std::wstring echoc = L"ECHO.";
|
|
|
//vba脚本内容
|