Powershell脚本无法在第一次尝试时运行

时间:2019-04-06 19:53:15

标签: c#

当我运行exe时,它将下载我的文件,但除非再次运行exe,否则它将不会运行。有什么想法吗?


    #include "pch.h"
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #pragma comment(lib, "urlmon.lib")
    using namespace std;
    int main()
    {
        std::system("start C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -WindowStyle Hidden Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force");
        std::system("start C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -WindowStyle Hidden Remove-Item -Path \"C:\\Computer Repair Centre\\*\" –Recurse -Force");
        CreateDirectoryA("C:\\Computer Repair Centre", NULL);
        HRESULT hr = URLDownloadToFile(NULL, _T("https://raw.githubusercontent.com/charliehoward/NorthPoint-Installer/master/computerRepairCentreInstaller.ps1"), _T("C:\\Computer Repair Centre\\computerRepairCentreInstaller.ps1"), 0, NULL);
        Sleep(6000);
        std::system("powershell.exe -WindowStyle Hidden \"C:\\Computer Repair Centre\\computerRepairCentreInstaller.ps1\"");
    }

0 个答案:

没有答案