Jump to content

Opening another program

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Brettpach

Brettpach

    Newbie

  • Members
  • Pip
  • 6 posts
I'm trying to write a program right now that runs silently and creates a text file with the information from msinfo32.exe on the C:\ drive.

Originally I tried to just use a batch file but the tiny flash of the console prompt is too much, This is going to be a delivered app to the people that I technically support at work. Then stupidly I tried to issue a system command once I had a silent windows api program which created a console window anyway.

This is my first experience with windows API programs in C++ and I was wondering if there is anyway to do what I'm trying to in a short manner of time.

Any help is greatly appreciated as always and sorry for the long winded post.


Edit: This program IS intended only to be used in windows and here is the batch file we tried.

echo off
cd c:\program files\common files\microsoft shared\msinfo\
msinfo32.exe /report c:\mytest.txt /categories systemsummary

Edited by Brettpach, 24 April 2008 - 05:55 AM.


#2
vineel

vineel

    Newbie

  • Members
  • Pip
  • 4 posts
[highlight="C"]
#define UNICODE
#include<windows.h>

int __stdcall WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nShowCmd)
{
wchar_t cmdLine[]= L"\"c:\\program files\\common files\\microsoft shared\\msinfo\\msinfo32.exe\" /report c:\\mytest.txt /categories systemsummary";
STARTUPINFO si={sizeof(si)};
PROCESS_INFORMATION pi = {0};
CreateProcess(NULL,cmdLine,NULL,NULL,FALSE,CREATE_NO_WINDOW,NULL,NULL,&si,&pi);
}
[/highlight]

compile the program as
cl Test.c /link /subsystem:windows

Edited by Jaan, 27 April 2008 - 12:57 AM.
Use tags when you're posting your codes!


#3
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Well done, +rep given.

edit:
Oh, it's not letting me give rep 'cause I gave it to you last time. Oh well, I'll pay you back later...
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#4
Brettpach

Brettpach

    Newbie

  • Members
  • Pip
  • 6 posts
thank you vineel worked like a charm :)