Solved

nbtstat & DOS commands

Posted on 2002-03-20
1
816 Views
Last Modified: 2012-08-13
I would like to find an option by which I can run all DOS commands in hidden mode.
For example I would like to use nbtstat command line utility from my MFC program, but when I use it I get an DOS window. I would like to hide the DOS window and run the command.


Thanks
saravana
0
Comment
Question by:vsaravana
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 6882639
Use 'CreateProcess()' to achieve that. Basically, what you have to do is to

BOOL ExecuteAndWaitForCompletion ( LPTSTR pszCmd) {

BOOL bRes;
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory ( &si, sizeof ( STARTUPINFO));

si.cb = sizeof ( STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;

    bRes     =     CreateProcess     ( NULL,
                                        pszCmd,
                                        NULL,
                                        NULL,
                                        TRUE,
                                        NORMAL_PRIORITY_CLASS,
                                        NULL,
                                        NULL,
                                        &si,
                                        &pi
                                       );

WaitForSingleObject     (     pi.hProcess,     INFINITE);

CloseHandle( pi.hProcess);
CloseHandle( pi.hThread);

return ( bRes);
}

(if you don't want this function to wait, remove the line containing 'WaitForSingleObject()')
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
object modeling - load and save functions 5 62
returning a dereferenced pts in C++ 10 158
Best book to learn C++ 4 84
Microsoft C++ code failing in executable that worked 9 110
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question