Solved

nbtstat & DOS commands

Posted on 2002-03-20
1
835 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

627 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