#include <iostream>
#include <windows.h>
main()
{
using std::cout;
using std::cin;
using std::endl;
int a;
cout << "================================";
cout << "== ==";
cout << "== For 32-bit enter 1 ==";
cout << "== For 64-bit enter 2 ==";
cout << "== ==";
cout << "================================";
cout << "\n\n\t=======> ";
cin >> a;
//If for 32-bit directory
if (a = 1)
{
system("cls");
system("cd c:\\ ");
//The space and the '\\' is so
//that cpp doesn't add the " to it
system("cd program file");
system("md MyProAlpha1.0");
}
//else for a (x86) directory
else
{
system("cls");
system("cd c:\\ ");
//The space and the '\\' is so
//that cpp doesn't add the " to it
system("cd program file (x86)");
system("md MyProAlpha1.0");
}
system("pause");
return 0;
}
But the problem is that the cd (change directory command, doesn't seem to work.
You should also be using the Win32API or 3rd Party Library to get the location of Program Files, and then using a file library for creating the directory. Doing it through system commands is a waste of time.
You can also put all of that into a single call.
1 2
system("mkdir C:\\Program Files\\MyProAlpha1.0");
// Notice Program FileS not Program File
Poor example, and I don't have a compiler on this computer so not 100% sure if it works yet.
Plus if you wanted to make folder you could use CreateDirectory("C:/X", NULL); //create folder
Hope this helps.
LittleQuick, I would use your code, but I don't understand what any of it is. Again, I'm still very new, I just know what I need C++ for. However accomplishing my task is much harder. I'd be interested in learning that code, if you have the time and desire to break it down a little. Thanks either way though.
A batch file has no relation to C++. What I am trying to say is, the problem you're trying to solve is not something that you'd really need to go through all of the hassle of writing an application for when you could write a small script to do it easily. However; if you were going to use C++ then you might as well use something like the Boost library and the WindowsAPI to do it properly.
Thanks. Last question is there a way to execute an xcopy or copy from the current directory to another without having to know the current directory.
Copy folder MyProgramAlpha1.0 >> program files (with unknown directory)
But the .exe is in the MyprogramAlpha1.0
I'm really sorry for being a pain.
When I first stated learning C the first thing I read in multiple places was
"C++ or any programing language is for people who can think logically, more than rationally" I'm starting to understand what they meant :(
This sound's like your trying to build yourself an installer. Why don't you just download one of the free installation building applications?
You also need to do some of the very very basic tutorials in C++. Things that are fundamental to writing even the most simple applications. I suggest you check out the tutorials section of this website.