Solved

nbtstat & DOS commands

Posted on 2002-03-20
1
824 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

752 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