Visual Studio: Opening Windows

OK.

Weird question.
I want to make a program in C++ that can open a exe that the user probably already has (such as google), using a specific directory such as C:\ProgramData\Microsoft\Windows\Start Menu\Programs.


Don't tell me to walk before I can run I don't want to hear it, if it's impossible to do just tell me ok?


EDIT: IM USING VISUAL STUDIO
Last edited on
Use the system() call.
http://www.cplusplus.com/reference/cstdlib/system/?kw=system

 
    system ( <command-to-execute> );
its telling me "_________ is not recognized as an internal or external command,
operable program or batch file."
What are you trying to pass, and how are you passing it?
The format of the argument to system() should be the same as you would type at a command prompt.

Assuming notepad is in one of the directories on the command path,
 
    system ( "notepad <file to open> ); 

its telling me "_________ is not recognized as an internal or external command,
operable program or batch file."
I'll be more blunt: How are we supposed to help you if you don't show us any code?
Grust697 wrote:
Weird question.
I want to make a program in C++ that can open a exe that the user probably already has (such as google), using a specific directory such as C:\ProgramData\Microsoft\Windows\Start Menu\Programs.
What do you mean by 'using a specific directory...'? Do you want to find the program to run here or use that directory as the working directory?

and wrote:
Don't tell mew to walk before I can run I don't want to hear it, if it's impossible to do just tell me ok?
It would be hard to say if it is impossible as your questions so far have been vague at best. If you can't explain clearly what you require the code to do, we can only give you a vague idea of a solution.
Grust697 wrote:
Weird question.

Yep.


Grust697 wrote:
the user probably already has (such as google)

Couldn't find google.exe in my system anywhere.


Grust697 wrote:
Don't tell mew to walk

mew ... SIT!


Grust697 wrote:
I don't want to hear it

I think we got the message.


Grust697 wrote:
EDIT: IM USING VISUAL STUDIO

And?


Grust697 wrote:
its telling me "_________ is not recognized as an internal or external command,
operable program or batch file."

No, well _________ isn't a valid file on my system, either.


Just show your code.

At a rough guess, '\' is getting picked up as an escape symbol in a string, so you would need either to double it up or use a raw string. But who knows - you aren't showing your code.


Last edited on
https://www.daniweb.com/programming/software-development/threads/182859/possible-to-launch-a-exe-using-c-code

And this can all be set in the command line arguments
refer https://www.geeksforgeeks.org/command-line-arguments-in-c-cpp/

Doesn't matter much what IDE is being used. (aside from the fact that .exe files are for windows vs mac)
I used _______ instead of directory of the file, because the directory had my fullname in it lel
so it would be like C:___/____/____/

the __ are blanks fyi not an actual file haha
Windows can get rather snotty about doing system commands from what it considers are protected system folders. Your app might need system admin level authority.

You might want to muck around with doing system commands on a user created temp folder.
so it would be like C:___/____/____/


No, in Windows it would be more like
"c:\\___\\___\\___"
because \ (note the direction of the slash) will be treated as an escape character unless you either double it up or use raw strings.

You have yet to show any code. I'm sure that you can amend it to disguise your name or any ulterior designs on the filesystem of your computer.
Last edited on
This is what I've been told by this thread so I threw something together here.
1
2
3
4
5
6
7
8
9
10
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
	cout<<"You wanted code so here you  go :D";
	system("C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories");


}

That's my code so far. When ran, it says something about insufficient system resources? What's is wrong now?

EDIT: This code is attempting to run "Notepad".
Last edited on
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <windows.h>

using namespace std;
int main()
{
	cout << "You wanted code so here you  go :D";
	system("\"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories\\Notepad.lnk\"");
}
@Grust697,
Your code doesn't even mention notepad - why on earth do you expect it to run it?

Incidentally, the start menu largely contains links - it's more sensible to go straight to the location of notepad.exe.
oops copied the wrong directory haha
Topic archived. No new replies allowed.