|
I'm using a remote execution tool called 'PsExec' from sysinternals.
I use it this way in my command prompt :
D:\Tools\Testing>psexec netsh firewall show opmode>D:\Log.txt
This generates the output for 'netsh firewall show opmode' and redirects to D:\Log.txt
Now, I implement the same logic/code in my application like this :
CString csCmdLineParams = "netsh firewall show opmode>D:\\TestdwLog.txt";
STARTUPINFO StartUpInfo;
PROCESS_INFORMATION ProcInfo;
DWORD ExitCode = -1;
memset(&StartUpInfo, 0, sizeof(StartUpInfo));
memset(&ProcInfo, 0, sizeof(ProcInfo));
StartUpInfo.dwFlags = STARTF_USESHOWWINDOW;
StartUpInfo.wShowWindow = SW_SHOW;
CreateProcess( "C:\\windows\\system32\\cmd.exe", csCmdLineParams.GetBuffer(csCmdLineParams.GetLength() + ONE), NULL, NULL, NULL, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &StartUpInfo, &ProcInfo);
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcInfo.hProcess, &ExitCode );
if (ExitCode) {
csCmdLineParams.ReleaseBuffer();
CloseHandle(ProcInfo.hProcess);
}
csCmdLineParams.ReleaseBuffer();
CloseHandle(ProcInfo.hProcess);
But, I'm not able to redirect the output to D:\TestdwLog.txt. In fact the file is not created itself.
Note : I do have administrator rights for my system. [required for PsExec]
What am I doing wrongly ?
I also tried
StartUpInfo_IDI.dwFlags = STARTF_USESTDHANDLES; instead of StartUpInfo.dwFlags = STARTF_USESHOWWINDOW;
Replies would be appreciated
Thanks in advance.
|
|
|
|
|
|
Put psexec netsh firewall show opmode>D:\Log.txt in a batch file, and run the batch file from CreateProcess() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks David.
This works.
Also found another option of using system()
Thanks
|
|
|
|
|
I know how to use the MS XML Parser in VC++ 6. For instance, I can do a #import the dll using the appropriate namespace.
But this does not seem to work in VC++ 2005 Express Edition...
What do I need to do so that I could use MSXML parser in my C++ sources which are to be compiled with the free VC++ 2005 Express Edition alone (and no other compiler)?
Please provide pointers to any helpful articles/pages here or elsewhere.
Thanks in advance.
|
|
|
|
|
What's the error you are getting? when you do an import in VS2005?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
To use #import with an Express edition, you need to remove any mention of ATL (as the express editions don't ship with ATL). That means no smart pointers, no wrappers for VARIANT or BSTR . You can tell #import not to use ATL with attributes (see the second example below).
So, it can be done, but it means going from code like this:
#include <tchar.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#include <atlbase.h>
#include <atlstr.h>
#include <iostream>
#import <progid:Msxml2.DOMDocument.6.0> rename_namespace("TestNS")
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(0, COINIT_MULTITHREADED);
TestNS::IXMLDOMDocument3Ptr pDoc(__uuidof(TestNS::FreeThreadedDOMDocument60));
pDoc->load("CHange-History.xml");
pDoc->setProperty("SelectionLanguage", "XPath");
TestNS::IXMLDOMNodeListPtr selected = pDoc->documentElement->selectNodes("//configuration");
long nodeCount;
selected->get_length(&nodeCount);
std::cout << nodeCount << " configuration nodes\n";
CoUninitialize();
return 0;
}
to code like this (it runs and gives the same answer as the code above, but I'm not sure that I manage resources correctly....
#include <tchar.h>
#include <iostream>
#import <progid:Msxml2.DOMDocument.6.0> rename_namespace("TestNS") raw_interfaces_only no_implementation no_smart_pointers raw_native_types
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(0, COINIT_MULTITHREADED);
TestNS::IXMLDOMDocument3* pDoc;
HRESULT hr;
if (SUCCEEDED(hr = ::CoCreateInstance(__uuidof(TestNS::FreeThreadedDOMDocument60), 0, CLSCTX_ALL, __uuidof(TestNS::IXMLDOMDocument3), (void**)&pDoc)))
{
BSTR file = ::SysAllocString(L"CHange-History.xml");
VARIANT vFile;
V_VT(&vFile) = VT_BSTR;
V_BSTR(&vFile) = file;
VARIANT_BOOL loadedOK;
if (SUCCEEDED(hr = pDoc->load(vFile, &loadedOK) && loadedOK == VARIANT_TRUE))
{
BSTR propName = ::SysAllocString(L"SelectionLanguage");
BSTR selectionLanguage = ::SysAllocString(L"XPath");
VARIANT vSelLang;
V_VT(&vSelLang) = VT_BSTR;
V_BSTR(&vSelLang) = selectionLanguage;
TestNS::IXMLDOMElement* docElement;
BSTR xpath = ::SysAllocString(L"//configuration");
TestNS::IXMLDOMNodeList* selected;
if (SUCCEEDED(hr = pDoc->setProperty(propName, vSelLang)))
{
if (SUCCEEDED(hr = pDoc->get_documentElement(&docElement)))
{
if (SUCCEEDED(hr = docElement->selectNodes(xpath, &selected)))
{
long nodeCount;
if (SUCCEEDED(selected->get_length(&nodeCount)))
{
std::cout << nodeCount << " configuration nodes\n";
}
selected->Release();
}
docElement->Release();
}
}
::SysFreeString(xpath);
::SysFreeString(propName);
::SysFreeString(selectionLanguage);
}
::SysFreeString(file);
pDoc->Release();
}
CoUninitialize();
return 0;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks, Stuart!
BTW, in the meanwhile, I have already made use of TinyXML because my requirements were very very simple. My document has a very simple (and predictable) structure that is just two/three levels deep... It doesn't have to to have validation...
Why TinyXML? Because, Google showed it above the others, that's why...
Thanks again, anyway, and bye for now
|
|
|
|
|
Ajit Jadhav wrote: TinyXML
Sounds like the right thing for your scenario.
Another option that might have suited you is RapidXML[^] - it's so small that it's contained in a single header file you #include into your code!
[edit]Or Microsoft's XmlLite[^], possibly[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi all,
I have a dll file which i want to use in my application before that i want to check the available functions in that so that i can decide whether to use it or not.
Please suggest me a way through which I can see the fucntions before usign it.
Thanks in advance....
|
|
|
|
|
API-funciton LoadLibrary() and GetProcAdress() will help. There is also a really great Tool from MS "depends.exe" which often helped me.
Greetings from Germany
|
|
|
|
|
i personally think you can use the tool which is supplied by VC6.0's "Dumpbin",which is in the "bin" file,open it and print the command "C:\Books\14>dumpbin ~~.dll /exports",then you can get the information about the exports method.
may you luck.
|
|
|
|
|
But i feel that depends.exe is a much better tool.
|
|
|
|
|
Hi I am newbie to Multithreading in C++
I have a static shared std::map< std::string >
I am 100% sure that it will be used only READ-ONLY after it has been filled up at startup of the application;
my question is: do I have to use thread synchronization to control the access to it or can I avoid?
Since it is read only, maybe I can skip using a mutex; is this a good idea?
Kind Regards
Manustone
|
|
|
|
|
You can as long as you only read it. Make it a const or with a const accessor function, to ensure it.
Greetings from Germany
|
|
|
|
|
|
Yes reading a container doesn't require synchronization usually.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
|
how to Set Monitor Contrast(0 to 100) using code.....
Plz help
|
|
|
|
|
You may get some hints from here...[^]
- ns ami -
|
|
|
|
|
Thanks for The Link.
But This COde is Setting The Brightness of Monitor but Not Contrast coz boht are Different Terms So i need to CHange the Contrast of Monitor .
Plz help further...
|
|
|
|
|
Hi,
I want to add Picture control Programmatically.Can any one suggest how to do it.Meanwhile I will also search.
I am using following code for creating static control in MFC Dialog.
CStatic * myStatic = new CStatic;
myStatic->Create( _T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(0,0,150,15), NULL );
delete myStatic;
But I am unable to creat it.
|
|
|
|
|
Try using this piece of code.
CStatic * myStatic = new CStatic;
myStatic->Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(10,10,150,50), this,1);
|
|
|
|
|
Hi,
I tried with the code you have given But no use.Do I need to change any Dialog Properties?
I am using this code in OnInitDialog function of Dialog class.
modified on Tuesday, February 24, 2009 3:08 AM
|
|
|
|
|
What is showing on the screen? is "my static" text displaying on the screen?
|
|
|
|