Solved

nbtstat & DOS commands

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Building cUrl in Windows v7.43.0 4 28
Implementing a ResolveEventHandler in C++ 13 116
C++ assignment question 7 169
gdb doesn't stop on breakpoint 2 50
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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.

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now