I am writing a small shell script for windows just for fun and was wondering how to open executable programs? Can c++ do this?
Sturm 270 Veteran Poster
Recommended Answers
Jump to PostC++ can do anything which you could do from the command prompt, using the system() function - eg, (Assuming some version of DOS or Windows)
system("dir"); //DOS Command to show a directory listing system("pause"); //DOS command to make a pause happen
Jump to PostYup, use the system() command. For example:
system("DIR C:\");
lists the contents of the C:\ drive. Simply enter in the path of the script, and you're good to go.
Hope this helps
[edit]Too slow...[/edit]
Presumably you meant
system("DIR C:\\");
Jump to Postmy command prompt in Win2K doesn't like forward-slashes when used with commands (such as ' dir c:/ ' - the command complains that i'm using an invalid switch ). Although its ok when specifying the path of an executable - eg ' c:/winnt/explorer.exe '
Jump to PostThats because the forward slash is actually not required for the purpose you are trying to achieve. You can do
system( "dir c:" )
and get the same results.That was a bad example. dir C:/WinNT might be a better one :)
All 14 Replies
Bench 212 Posting Pro
John A 1,896 Vampirical Lurker Team Colleague
dwks 149 Posting Whiz in Training
Sturm 270 Veteran Poster
John A 1,896 Vampirical Lurker Team Colleague
Bench 212 Posting Pro
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Bench 212 Posting Pro
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Sturm 270 Veteran Poster
Ravalon 62 Posting Whiz in Training
Bench 212 Posting Pro
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
John A 1,896 Vampirical Lurker Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.