Windows detects my log program written with C is a virus

  c++, shortcut, virus, windows

i’m working on develop our log program. I try to create shortcut and add to start up but windows detect it’s a virus. Do I need to sign it first? if i sign it will my problem solve? Or is there any way to prevent this problem? Code is working btw

here is my code:

#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <direct.h>

int main(void)
{
    char shortcut[1000];
    char* appdata = getenv("APPDATA");  // C:Users<yourusername>AppDataRoaming
    //printf("%sn", appdata);
    strcpy(shortcut, appdata);
    strcat(shortcut, "MicrosoftWindowsStart MenuProgramsStartup");

    char* cwd;

    // Get the current working directory:
    if ((cwd = _getcwd(NULL, 0)) == NULL)
        perror("_getcwd error");
    else
    {
        printf("%sn", cwd);
        //free(buffer);
    }

    char* _write_copy = "start powershell.exe $WshShell = New-Object -comObject WScript.Shell; "  
        "$Shortcut = $WshShell.CreateShortcut('%slogger.exe.lnk');"  
        "$Shortcut.TargetPath ='%slogger.exe';"  
        "$Shortcut.Save(); exit"; 

    char write_copy[1000];

    sprintf(write_copy, _write_copy, shortcut, cwd);
    system(write_copy);


    return 0;
}

Source: Windows Questions

LEAVE A COMMENT