Hide prompt when running system() command?

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2008
Posts: 4
Reputation: Zach1188 is an unknown quantity at this point 
Solved Threads: 0
Zach1188 Zach1188 is offline Offline
Newbie Poster

Hide prompt when running system() command?

 
0
  #1
Dec 28th, 2008
I have a fairly simple question, which may or may not have a simple solution. How can I run the system(); command, in a win32 (not console) application, without the black command prompt window flashing on the screen?

If relevant, I am using Dev-C++.
Last edited by Zach1188; Dec 28th, 2008 at 12:20 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 206
Reputation: grumpier has a spectacular aura about grumpier has a spectacular aura about 
Solved Threads: 31
grumpier grumpier is offline Offline
Posting Whiz in Training

Re: Hide prompt when running system() command?

 
0
  #2
Dec 28th, 2008
The short answer is that you can't. The system() function (it's not a command) supported by win32 compilers/libraries starts up a command shell, and that command shell shows the "black command prompt window".

If you actually need a command shell (eg you're running an inbuilt shell command or executing a .BAT file), then you have no choice. However, you might be able to find a way to implement your required functionality without using a command shell.

If you want to run a third-party program (eg another win32 application) with more control than is possible with the system() command, look up the CreateProcess() function in the win32 API.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 640
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 104
Murtan Murtan is offline Offline
Practically a Master Poster

Re: Hide prompt when running system() command?

 
0
  #3
Dec 28th, 2008
I agree with grumpier, if you have to use the system() call, you're stuck with the "black window". But unless you're calling batch files, you can probably avoid the system() call.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 4
Reputation: Zach1188 is an unknown quantity at this point 
Solved Threads: 0
Zach1188 Zach1188 is offline Offline
Newbie Poster

Re: Hide prompt when running system() command?

 
0
  #4
Dec 28th, 2008
I know, system() isn't a command, I was in a hurry when I wrote that.

Well, basically what I'm trying to do is make a program that automatically starts the user in the SYSTEM account (if you've seen guides on how to do that). It's not a particularly "useful" program, but it's good practice. I am trying to use the "at" command using /interactive to start explorer.exe as SYSTEM.

Example:
  1. std::string cmd = "at " + calcTime(1) + " /interactive explorer.exe";
  2. system(cmd.c_str());

Perhaps this is was a stupid question, I suppose I could use CreateProcess() to run at.exe. Am I correct?
Last edited by Zach1188; Dec 28th, 2008 at 2:56 am.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 640
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 104
Murtan Murtan is offline Offline
Practically a Master Poster

Re: Hide prompt when running system() command?

 
0
  #5
Dec 28th, 2008
at.exe is in my system32 directory, so I suspect you could use CreateProcess on it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 1731 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC