|
|
@@ -1649,6 +1649,7 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
ErrorCodeEnum rc = Error_InvalidState;
|
|
|
const int setType = InitialAutoStartupSetType();
|
|
|
bool toCheckAndDelteAutostartFile(false);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("current startup type:%d, aim start type:%d", nStartupType, setType);
|
|
|
switch (setType)
|
|
|
{
|
|
|
case 1://将VBS改成EXE,前提是VBS必须已在注册表
|
|
|
@@ -1668,25 +1669,31 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
if (nStartupType == 1 || nStartupType == 2) {
|
|
|
rc = ChangeAutoStartupWithExe(false, true);
|
|
|
}
|
|
|
- else if (nStartupType == 3) {
|
|
|
+ else if (nStartupType == 3 || nStartupType == 4) {
|
|
|
toCheckAndDelteAutostartFile = true;
|
|
|
}
|
|
|
break;
|
|
|
case 4: //恢复VBS启动(防止EXE启动失败)
|
|
|
- if (nStartupType == 2 || nStartupType == 0 || nStartupType == 3) {
|
|
|
+ if (nStartupType == 2 || nStartupType == 0) {
|
|
|
rc = ChangeAutoStartupWithExe(true);
|
|
|
- if (rc == Error_Succeed && nStartupType == 3) {
|
|
|
- toCheckAndDelteAutostartFile = true;
|
|
|
- }
|
|
|
}
|
|
|
break;
|
|
|
+ case 5: //设置使用EXE自启动(涵盖所有类型)
|
|
|
+ if (nStartupType == 1 || nStartupType == 0 || nStartupType == 3 || nStartupType == 4) {
|
|
|
+ rc = ChangeAutoStartupWithExe();
|
|
|
+ if (rc == Error_Succeed && (nStartupType == 3 || nStartupType == 4)) {
|
|
|
+ toCheckAndDelteAutostartFile = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (toCheckAndDelteAutostartFile) {
|
|
|
CSimpleStringA strLnkPath(true);
|
|
|
- if (IsHasSetAutoStartupByFolder(strLnkPath) && !strLnkPath.IsNullOrEmpty()) {
|
|
|
+ bool scriptTypeOrNot;
|
|
|
+ if (IsHasSetAutoStartupByFolder(strLnkPath, scriptTypeOrNot) && !strLnkPath.IsNullOrEmpty()) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("remove auto start lnk file: %s", strLnkPath.GetData());
|
|
|
RemoveFileA(strLnkPath);
|
|
|
}
|
|
|
@@ -1768,9 +1775,17 @@ int ResourceWatcherFSM::DetectAutoStartupType()
|
|
|
|
|
|
if (vbsType == 0 || vbsType == -1) {
|
|
|
CSimpleStringA strLnkPath(true);
|
|
|
- if (IsHasSetAutoStartupByFolder(strLnkPath)) {
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_WARN_CHECK_AUTO_STARTUP_WITH_STARTMENU, strLnkPath);
|
|
|
- vbsType = 3;
|
|
|
+ bool scriptType = false;
|
|
|
+ if (IsHasSetAutoStartupByFolder(strLnkPath, scriptType)) {
|
|
|
+ if (!scriptType) {
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_WARN_CHECK_AUTO_STARTUP_WITH_STARTMENU_FROMSETUP, strLnkPath);
|
|
|
+ vbsType = 3;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_WARN_CHECK_AUTO_STARTUP_WITH_STARTMENU_FROMSCRIPT, strLnkPath);
|
|
|
+ vbsType = 4;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
return vbsType;
|
|
|
@@ -1854,11 +1869,14 @@ int ResourceWatcherFSM::InitialAutoStartupSetType()
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-BOOL ResourceWatcherFSM::IsHasSetAutoStartupByFolder(CSimpleStringA& strPath)
|
|
|
+BOOL ResourceWatcherFSM::IsHasSetAutoStartupByFolder(CSimpleStringA& strPath, bool& scriptsType)
|
|
|
{
|
|
|
BOOL result(FALSE);
|
|
|
+
|
|
|
strPath.Clear();
|
|
|
+ scriptsType = false;
|
|
|
const char* STARTUP_DIR_FULL_PATH = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp";
|
|
|
+ const char* STRATUP_FILENAME_FROM_SCRIPTS = "spexplorerauto.lnk";
|
|
|
|
|
|
#ifdef DEVOPS_ON_ST /*DevOps流水线编译,ST环境*/
|
|
|
const char* CMB_LINK_FILE_NAME = "招商银行可视柜台(ST测试).lnk";
|
|
|
@@ -1902,6 +1920,38 @@ BOOL ResourceWatcherFSM::IsHasSetAutoStartupByFolder(CSimpleStringA& strPath)
|
|
|
toolkit_array_free2(arr);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (!result) {
|
|
|
+ CSimpleStringA fullStartFileNameFromScripts(STARTUP_DIR_FULL_PATH);
|
|
|
+ fullStartFileNameFromScripts += "\\";
|
|
|
+ fullStartFileNameFromScripts += STRATUP_FILENAME_FROM_SCRIPTS;
|
|
|
+ if (ExistsFileA(fullStartFileNameFromScripts)) {
|
|
|
+ strPath = fullStartFileNameFromScripts;
|
|
|
+ scriptsType = true;
|
|
|
+ result = TRUE;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // Get and display the user name.
|
|
|
+ const DWORD INFO_BUFFER_SIZE = 2048;
|
|
|
+ char infoBuf[INFO_BUFFER_SIZE];
|
|
|
+ ZeroMemory(infoBuf, INFO_BUFFER_SIZE);
|
|
|
+ DWORD bufCharCount = INFO_BUFFER_SIZE;
|
|
|
+ if (!GetUserName(infoBuf, &bufCharCount)) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetUserName failed, GLE=%u", GetLastError());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("User name:%s", infoBuf);
|
|
|
+ fullStartFileNameFromScripts = CSimpleStringA::Format("C:\\Users\\%s\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup", infoBuf);
|
|
|
+ fullStartFileNameFromScripts += "\\";
|
|
|
+ fullStartFileNameFromScripts += STRATUP_FILENAME_FROM_SCRIPTS;
|
|
|
+ if (ExistsFileA(fullStartFileNameFromScripts)) {
|
|
|
+ scriptsType = true;
|
|
|
+ strPath = fullStartFileNameFromScripts;
|
|
|
+ result = TRUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|