![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
|
Spaces in system() function
So it's time I ventured into C++. In my attempt to make a quick and useful program, i'm coming across a problem. How can I use spaced in the system() function to call a program living in the program files folder?
|
|
|
|
|
|
#2 | |
|
Programmer
Join Date: Dec 2005
Posts: 53
Rep Power: 3
![]() |
Quote:
system("\"c:\\Program Files\\YourApp.exe\"");You have to add quotations around it so that it won't parse it as a command followed by an argument list. |
|
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
I think
system("C:\\Program files\\myexe.exe");system("C:/Program files/myexe.exe");Edit: shouldn't leave the tab open for a long time.
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
#4 |
|
Professional Programmer
|
hmm...none of it is working. here's my code, everything commented out i've tried and doesn't work.It's basically supposed to unmount an alcohol120% virtual drive.
#include <iostream>
using namespace std;
int main()
{
// system("C:\program\ files\alcohol soft\alcohol 120\AxCmd.exe E: /u");
// system("\"C:\program\ files\alcohol soft\alcohol 120\AxCmd.exe E: /u\"");
system("C:\\Program\ files\\alcohol\ soft\\alcohol\ 120\\AxCmd.exe\ E:\ /u");
system("PAUSE");
return EXIT_SUCCESS;
}they all give me the error: 'C:\Program' is not recognized as an internal or external command, operable program or batch file. Press any key to continue . . . |
|
|
|
|
|
#5 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
#include <iostream>
using namespace std;
int main()
{
system("C:\\program files\\alcohol soft\\alcohol 120\\AxCmd.exe E: /u");
system("PAUSE");
return EXIT_SUCCESS;
}
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
nope, same thing. Is just converting it to the short path name the best way to go? Like at http://www.tek-tips.com/viewthread.c...1218192&page=1
|
|
|
|
|
|
#7 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
you can try the 6 char trick:
system("C:\\Progra~1\\alcoho~1\\alcoho~1\\'AxCmd.exe E: /u'"); |
|
|
|
|
|
#8 | |
|
Professional Programmer
|
Quote:
system("C:\\Progra~1\\alcoho~1\\alcoho~1\\AxCmd.exe E: /u"); |
|
|
|
|
|
|
#9 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#10 | |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Quote:
. I still use Dos every now and then just for good childhood memories. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|