943,633 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2300
  • C RSS
Feb 25th, 2009
0

Hw to execute dos commands in C

Expand Post »
I need to execute some dos commands like executables(.exe)
PLEASE HELP ME OUT OF THIS
Last edited by abhi_marichi; Feb 25th, 2009 at 1:25 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
abhi_marichi is offline Offline
18 posts
since Dec 2007
Feb 25th, 2009
0

Re: Hw to execute dos commands in C

I need to execute some dos commands like executables(.exe)
PLEASE HELP ME OUT OF THIS
Read more about the "system" command in C language.Your every requisite would get fulfilled.
Through system command you can call all commands you can call in a command prompt mode and also execute certain kinds of files too.
Reputation Points: 485
Solved Threads: 88
Posting Pro
csurfer is offline Offline
564 posts
since Jan 2009
Feb 26th, 2009
0

Re: Hw to execute dos commands in C

Please, never use "system" command in C term in this context. No "commands" in C. The system is a library function in C...
Last edited by ArkM; Feb 26th, 2009 at 5:15 pm.
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Feb 26th, 2009
0

Re: Hw to execute dos commands in C

Take a look at ShellExecute

Edit: I misunderstood ArkM's post, I thought it was advising against the use of system() (as is usually the case). I suppose in this case, it would be okay?
Last edited by death_oclock; Feb 26th, 2009 at 5:53 pm.
Reputation Points: 128
Solved Threads: 43
Posting Whiz
death_oclock is offline Offline
389 posts
since Apr 2006
Feb 27th, 2009
0

Re: Hw to execute dos commands in C

I have never came out against this part of the C language Standard
It's exactly the program case for the system standard library function (not command)...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Feb 27th, 2009
0

Re: Hw to execute dos commands in C

Ah, I wasn't saying you always bash the system function, but whenever it appears in code just about everyone else goes crazy.
Reputation Points: 128
Solved Threads: 43
Posting Whiz
death_oclock is offline Offline
389 posts
since Apr 2006
Mar 2nd, 2009
0

Re: Hw to execute dos commands in C

>Arkm
>death_oclock
Well I couldn't really make out if you people were against usage of system library function here in this context.If yes could you state the reason...?
Reputation Points: 485
Solved Threads: 88
Posting Pro
csurfer is offline Offline
564 posts
since Jan 2009
Mar 2nd, 2009
1

Re: Hw to execute dos commands in C

>Well I couldn't really make out if you people were against
>usage of system library function here in this context.
By my reading, death_oclock isn't sure, and ArkM hasn't stated a preference.

>If yes could you state the reason...?
In this case, system is still risky, but no more risky than ShellExecute as they both have the same vulnerability: unless you're careful about the path you pass, a malicious program can be run in place of the one you expected.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Mar 2nd, 2009
0

Re: Hw to execute dos commands in C

Click to Expand / Collapse  Quote originally posted by Narue ...
>Well I couldn't really make out if you people were against
>usage of system library function here in this context.
By my reading, death_oclock isn't sure, and ArkM hasn't stated a preference.

>If yes could you state the reason...?
In this case, system is still risky, but no more risky than ShellExecute as they both have the same vulnerability: unless you're careful about the path you pass, a malicious program can be run in place of the one you expected.
Path is still a user input right ? As both system and ShellExecute have same problems on the system side execution,its just the path which determines whether it would suit this application or not.
So once we are sure that the path given by user is right the system(<path>) should not create any problem.Isn't it Naure?
Reputation Points: 485
Solved Threads: 88
Posting Pro
csurfer is offline Offline
564 posts
since Jan 2009
Mar 2nd, 2009
1

Re: Hw to execute dos commands in C

>Path is still a user input right ?
I don't know, the OP changed his post so that it no longer specifies.

>So once we are sure that the path given by user is right
>the system(<path>) should not create any problem.
It can still create problems, but those problems aren't something you can easily control with code.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Array to an output file
Next Thread in C Forum Timeline: Ethernet forwarding in Linux using C





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC