|
-
April 21st, 2009, 10:50 AM
#1
How-To Stop Command-Prompt Window from appearing?
Hello
I'm trying to write in some program launchers into 1 programmed .exe.
Here is my code;
Code:
#include <iostream>
using namespace std;
int main()
{
system("explorer \\panarchy\\share");
system("\"\"%ProgramFiles%\\Symantec\\LiveUpdate\\LUALL.exe\"\"");
system("diskmgmt.msc");
}
Please tell me how I can stop the command-prompt window from appearing.
Thanks in advance,
Panarchy
PS: If you could also tell me how to add an icon to the finished project with Code::Blocks, I'd really appreciate it! Thanks
-
April 21st, 2009, 11:15 AM
#2
Re: How-To Stop Command-Prompt Window from appearing?
Well this problem is by design.
You need to call it a different way.
the best way as was mentioned by other members was createprocess().
then there is winexec().
By the way what you are doing is called cross-posting and is most annoying to the list members who are trying to help you. It is considered rude.
ahoodin
To keep the plot moving, that's why.

-
April 21st, 2009, 04:32 PM
#3
Re: How-To Stop Command-Prompt Window from appearing?
Thanks, I'm trying them but I keep getting errors.
Can you please give me the context of the code?
(the code before I start opening programs with winexec or createprocess)
Thanks in advance,
Panarchy
-
April 22nd, 2009, 01:01 AM
#4
Re: How-To Stop Command-Prompt Window from appearing?
Hello
I got it to work pretty much perfectly now!

Code:
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE hprevious, LPSTR cmdline, int cmdshow) {
ShellExecute(NULL, TEXT("open"), TEXT("explorer"), TEXT("\\Panarchy\\share"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("diskmgmt.msc"), NULL, NULL, SW_HIDE);
return 0;
}
If you could just tell me how to stop the command-prompt window from appearing at the start of the program, then the program would be complete!
Thanks in advance,
Panarchy
PS: Still don't know how to add an icon to it within Code::Blocks... would appreciate advice on how to do this.
Last edited by Panarchy; April 22nd, 2009 at 02:04 AM.
-
April 22nd, 2009, 04:39 AM
#5
Re: How-To Stop Command-Prompt Window from appearing?
I've been able to get it more than 80% complete.
Here is my code;
Code:
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE hprevious, LPSTR cmdline, int cmdshow) {
ShellExecute(NULL, TEXT("open"), TEXT("\"\"%ProgramFiles%\\Symantec\\LiveUpdate\\LUALL.exe\"\""), NULL, NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("explorer"), TEXT("\\Panarchy\\share"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("schedtasks\0"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("sysdm.cpl"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("diskmgmt.msc"), NULL, NULL, SW_HIDE);
return 0;
}
For some reason, everything works... apart from the first line (the Symantec one).
Does anyone know how I can get that to work?
I used to use the system command, this works, however shows the command-prompt window (until it exits);
Code:
system("\"\"%ProgramFiles%\\Symantec\\LiveUpdate\\LUALL.exe\"\"");
Please tell me what needs to be done in order to stop the command-prompt window from opening, incorporate an icon & get the LiveUpdate program to load with ShellExecute.
Thanks in advance,
Panarchy
-
April 22nd, 2009, 07:57 AM
#6
Re: How-To Stop Command-Prompt Window from appearing?
Hello Everyone.
Thanks for all your help over the topics.
Here's an update;
I fixed the command-prompt window from appearing by installing Code::Blocks on an XP virtual machine, creating a new project (Win32 GUI) with Dialogue Based (or something).
As far as I can tell, all this added was a #include "resource.h" line.
I have also gotten the %programfiles% thing fixed up as well.
Code:
#include <windows.h>
#include <tchar.h>
#include <iostream>
#ifdef UNICODE
#define tcout wcout
#else
#define tcout cout
#endif
int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE hprevious, LPSTR cmdline, int cmdshow) {
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
TCHAR lpCmdLine[MAX_PATH] = {0};
::ExpandEnvironmentStrings(_T("\"%ProgramFiles%\\Symantec\\LiveUpdate\\LUALL.exe\""),
lpCmdLine, MAX_PATH);
std::tcout << _T("Command line : ") << lpCmdLine << std::endl;
BOOL bRet = ::CreateProcess(NULL, lpCmdLine, NULL, NULL, FALSE,
CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
ShellExecute(NULL, TEXT("open"), TEXT("explorer"), TEXT("\\Panarchy\\share"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("schedtasks\0"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("sysdm.cpl"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("diskmgmt.msc"), NULL, NULL, SW_HIDE);
return 0;
}

Works perfectly now.
One final question, how do I give the program an icon within Code::Blocks?
Please reply.
Thanks in advance,
Panarchy
Last edited by Panarchy; April 22nd, 2009 at 08:06 AM.
-
April 22nd, 2009, 04:33 PM
#7
Re: How-To Stop Command-Prompt Window from appearing?
[quote author=Urxae link=topic=991.msg6837#msg6837 date=1128033880]
The first icon in your resource file will be used as the icon of the executable. You'll have to create your resource file manually though, AFAIK Code::Blocks does not have a dialog for it like Dev-cpp. It's not extremely hard, just put something like this in it:
Code:
MY_ICON ICON "my_icon.ico"
The first word is the name of the icon (not important unless you want to refer to it in your code), the second word indicates it's an icon and then comes the name of the file to use.
[/quote]
8)
That worked for me!
SWEET - My project has been perfected!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|