1.删除这个路径下的文件 C:\ProgramData\SafeNet Sentinel,注意ProgramData好像是隐藏文件
2.在Windows 的Cmd 界面,前往Unity.exe的路径
繁琐操作就是用cd …和dir去一层层找;快捷的话需要知道具体路径。
cd …进入上层目录;
dir显示当前目录下所有文件;
cd Program Files则可以进入Program Files文件夹,同理操作“cd+空格+文件夹名字”
3.最后输入这个 hasp_update.exe u unity-sl.v2c
上述步骤,本人已写了自动操作工具: h007.7z
#include <iostream> #include <direct.h> #include <filesystem> #include <windows.h> #include <string> using namespace std; bool delete_directory(const std::string& dir_path) { WIN32_FIND_DATAA find_file_data; HANDLE hFind = FindFirstFileA((LPSTR)(dir_path + "\\*").c_str(), &find_file_data); if (hFind == INVALID_HANDLE_VALUE) { return false; } do { const std::string file_name = find_file_data.cFileName; const std::string full_file_name = dir_path + "\\" + file_name; if (file_name == "." || file_name == "..") { continue; } if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { delete_directory(full_file_name); } else { DeleteFileA((LPSTR)full_file_name.c_str()); } } while (FindNextFileA(hFind, &find_file_data) != 0); FindClose(hFind); return RemoveDirectoryA(dir_path.c_str()) != 0; } void ExecuteHASPUpdate(const std::string& directory) { std::string command = directory + "\\hasp_update.exe u unity-sl.v2c"; STARTUPINFOA si = { sizeof(STARTUPINFO) }; PROCESS_INFORMATION pi; if (!CreateProcessA(NULL,(LPSTR)command.c_str(),NULL,NULL,FALSE,0,NULL,directory.c_str(),&si,&pi)) { std::cerr << "执行命令行失败: " << command << ". 错误: " << GetLastError() << std::endl; } else { WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); std::cout << "执行完毕,请检查Untiy是否正能正常打开" << std::endl; std::cout << "有问题请反馈 QQ:29535065" << std::endl; } } void FindUnityExe(const std::string& directory) { WIN32_FIND_DATAA findFileData; std::string searchPath = directory + "\\*"; HANDLE hFind = FindFirstFileA(searchPath.c_str(), &findFileData); if (hFind == INVALID_HANDLE_VALUE) { std::cerr << "查找句柄失败: " << directory << std::endl; return; } do { const std::string fileOrDirName = findFileData.cFileName; if (fileOrDirName == "." || fileOrDirName == "..") { continue; } if (fileOrDirName.find("Unity") == std::string::npos && fileOrDirName.find("Editor") == std::string::npos) { continue; } std::string fullPath = directory + "\\" + fileOrDirName; // cout << fullPath << endl; if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { FindUnityExe(fullPath); } else if (fileOrDirName == "unity.exe" || "Unity.exe"== fileOrDirName) { std::cout << "找到unity目录: " << directory << std::endl; ExecuteHASPUpdate(directory); } } while (FindNextFileA(hFind, &findFileData) != 0); FindClose(hFind); } int main(){ std::string folderPath = "C:\\ProgramData\\SafeNet Sentinel\\Sentinel LDK"; if (!delete_directory(folderPath)) { std::cerr << "删除目录失败" << std::endl; //return -1; } else { std::cout << "目录及其内容已成功删除" << std::endl; } FindUnityExe("C:\\Program Files"); return 0; }
0 评论