User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,588 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,634 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 311 | Replies: 8
Reply
Join Date: Apr 2008
Location: PLANET EARTH
Posts: 33
Reputation: Dannyo329 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Dannyo329's Avatar
Dannyo329 Dannyo329 is offline Offline
Light Poster

Opening an .exe file with C++

  #1  
33 Days Ago
Well. I 'm trying to get a program in C++(MS-DOS) to open another .exe file. I thought there might have been a way with the:
system ("main.exe") ;
to call it, but somehow it does not work and its like it skips it completely.
I'd appreciate any help. Thankyou.
(Sorry about the title, i meant execute an .exe)
Last edited by Dannyo329 : 33 Days Ago at 4:05 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,562
Reputation: niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough 
Rep Power: 8
Solved Threads: 158
niek_e's Avatar
niek_e niek_e is offline Offline
Posting Virtuoso

Re: Opening an .exe file with C++

  #2  
33 Days Ago
your statement should actually work. Perhaps you got the path wrong? You could try something like:
  1. system("c:\\mydir\\heres_the_file\\main.exe")

Is it absolutely necessary to open main.exe? I personally don't like the system() command, because if someone would replace the "main.exe" program with a renamed version of "format C: /q" you would be in a hell of a lot of trouble
Last edited by niek_e : 33 Days Ago at 4:21 am.
do NOT pm me for help, it makes me angry. You wouldn't like me when I'm angry...
Reply With Quote  
Join Date: Apr 2008
Location: PLANET EARTH
Posts: 33
Reputation: Dannyo329 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Dannyo329's Avatar
Dannyo329 Dannyo329 is offline Offline
Light Poster

Re: Opening an .exe file with C++

  #3  
33 Days Ago
It works now, thanks.
Greetings Earthlings, I am your PROGRAMMER.
Reply With Quote  
Join Date: Jul 2008
Posts: 37
Reputation: Shadoninja is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Shadoninja Shadoninja is offline Offline
Light Poster

Re: Opening an .exe file with C++

  #4  
32 Days Ago
Originally Posted by niek_e View Post
if someone would replace the "main.exe" program with a renamed version of "format C: /q" you would be in a hell of a lot of trouble


what do you mean by "format C: /q"?

And what happens if you do?
Reply With Quote  
Join Date: Aug 2005
Posts: 4,663
Reputation: iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice 
Rep Power: 16
Solved Threads: 297
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Opening an .exe file with C++

  #5  
32 Days Ago
What he means is that system calls suffer from security issues.


There's nothing to stop a user creating a program called main.cpp which may contain malicious code, then compiling it, and sitting that executable in the same directory as the other executable.

So when his other program calls system("main.exe") it would execute the virus/trojan/whatever.

In regards to what format c: /y does, it should format (wipe) your C:\ drive I believe, although I haven't tested it - obviously.
Last edited by iamthwee : 32 Days Ago at 4:30 am.
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,809
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 11
Solved Threads: 184
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Opening an .exe file with C++

  #6  
32 Days Ago
There is nothing inherently evil about system(), or executing other executables; just be aware that you must be careful how you do it.
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,543
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Opening an .exe file with C++

  #7  
32 Days Ago
Originally Posted by iamthwee View Post
There's nothing to stop a user creating a program called main.cpp which may contain malicious code, then compiling it, and sitting that executable in the same directory as the other executable.

So when his other program calls system("main.exe") it would execute the virus/trojan/whatever.

In regards to what format c: /y does, it should format (wipe) your C:\ drive I believe, although I haven't tested it - obviously.


So in that scenerao what is the difference between calling system(), CreateProcess() and ShellExecute() -- they all spawn other processes. system() is no more or less a security risk than any of the others.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Aug 2005
Posts: 4,663
Reputation: iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice 
Rep Power: 16
Solved Threads: 297
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Opening an .exe file with C++

  #8  
32 Days Ago
>So in that scenerao what is the difference between calling system()

There isn't. I never said it was more of a security risk.

I personally don't like the system() command, because if someone would replace the "main.exe"

I agree with you in the sense that the above quote has a flawed explanation. If you used shellexe createproc (whatever) it would have the same desired affect.
Last edited by iamthwee : 32 Days Ago at 8:52 pm. Reason: typoz
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,809
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 11
Solved Threads: 184
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Opening an .exe file with C++

  #9  
32 Days Ago
For the OP, the security danger is in executing less-privileged programs with more-privileged programs. That is, a low-level hax0r can write malicious code and get someone with access rights he doesn't have to execute his program. Doing so gives the executed program all the access rights as the calling program, and the maliciousness is unbounded.

Typically, programs will execute others under [edit]three[/edit] scenarios:
  1. As a user tool.
    Programs like Explorer or ObjectDock/Launcher/whatever or Irfanview, WinAmp, etc. need to execute other programs in order to satisfy the user's instructions. Explorer runs the program you double-click. Irfanview uses the QuickTime Player to play .mov files. Etc.
  2. As part of a known software system.
    For example, your IDE lets you edit programs: it may use OLE to embed an editor. It calls the compiler and linker and even programs like make to execute scripts that compile and link your program. The fancy GUI program you are using may only display the GUI and interact with the user. It could be actually doing stuff by executing other executables that came with the GUI. Often, the GUI itself is an external program. GIMP, for example, uses GTK, which is provided via a nice DLL sitting in your system32 directory. If you like Linux, your fancy calculators all farm out to bc to do the math. Etc.
  3. As an extension/add-on/plug-in/interpreter to add functionality to a program.
    For example, Softimage|XSI uses Perl to allow users to write scripts that do things the program doesn't do itself. Blender uses Python in the same way. (Both are 3D modelling and animation systems.) If you are reading this with Firefox right now, you have probably used some plugins to modify it somewhat. I'm using the Blue Ice 2 theme, and the Hide Menubar, Back/Forward Dropdown Remover, and Download Statusbar plugins. (They're great.) All these were written with some combination of scripting powers: XML, Javascript, VBScript, etc.
    Extra care must be taken with this kind of power, because unscrupulous people can easily execute their own evil scripts -- so the interpreter must be executed with less privilege than the calling program.
In [edit]all[/edit] cases, however, there is a degree of security. In the first, the user directly controls which processes he causes to execute. He (should) know what they are and what they do. In the second, the executed process came packaged as part of the executing process. If you trust one to execute, you can trust the other --since they are both from the same source. In the third, attempts to do something that is not permitted is simply not permitted -- the script/plug-in/whatever explicitly cannot do all the things the calling program can.

How's that for information overload?

Whew.
Last edited by Duoas : 32 Days Ago at 10:55 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:04 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC