ShellExecute - ERROR code 5

4.9k views Asked by At

I am using Notepad++ with TDM-GCC. My computer is 2Gb RAM Windows 10 32 bit 3.30 GHz. When I execute my simple program, it shows error.

Access is denied.
An attempt was made to execute the below command.
Command: D:\Deane\Github\CPP_Projects\AnalysisName\main.bat
Arguments:
Error Code: 5

Image of the error

I follow this: ShellExecuteEx function always returning error code 5 (C++)

Program's code (if necessary):

/* AnalysisName Program - written by Vo Tran Nha Linh */

#include <iostream> // Input and Output library.
using namespace std;

int main()
    {
    string name;
    cout << "Hello friend! It's nice to meet you, what is your name?" << endl;  // Ask the name.
    cin >> name; // Input name.
    cout << "Hello " << name << ". Your name is interesting." << endl; // Have a greeting.
    cout << "Your name has " << name.length() << "letters." << endl; // Show the name's length.
    cout << "It starts with " << name.front() << "letter." << endl; // Show the first letter of the name.
    cout << "It ends with " << name.back() << "letter." << endl; // Show the last letter of the name.

    return 0;

}

But it doesn't active, please give me a help. Thank you very much!

3

There are 3 answers

0
vtrnnhlinh On BEST ANSWER

My problem solved!

I miss Visual C++ Redistributable 2008 and 2010.

Moderators please close my topic. Thank you!

0
user18231415 On

this solved it for me: right click on the file that won't run (in my case a .cmd file) check the 'Unblock' checkbox next to the remark "This file came from another computer and might be blocked to help protect this computer"

1
mkr On

Navigate to C:\Program Files (x86)\Notepad++ Right mouse click the Notpad++.exe file click properties & under the compatability Tab UN-TICK run the program as administrator box DONE. Refer to this link.