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?
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,
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.
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.
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.
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.
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>
usingnamespace 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?
#include <iostream>
#include <windows.h>
usingnamespace std;
int main()
{
cout << "You wanted code so here you go :D";
system("\"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories\\Notepad.lnk\"");
}