EvilZone
Programming and Scripting => C - C++ => : bubzuru September 27, 2012, 03:08:33 AM
-
i need to delete a file using the COM FileSystemObject
vbs example
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("C:\users\bubzuru\desktop\test.txt")
any ideas about creating COM objects in C\C++
C examples would be better for me
-
CoCreateInstance() ?
-
CoCreateInstance() ?
yup that did it, now i need help with, with elevating the com object
take a look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms679687%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/ms679687%28v=vs.85%29.aspx)
HRESULT CoCreateInstanceAsAdmin(HWND hwnd, REFCLSID rclsid, REFIID riid, __out void ** ppv)
{
BIND_OPTS3 bo;
WCHAR wszCLSID[50];
WCHAR wszMonikerName[300];
StringFromGUID2(rclsid, wszCLSID, sizeof(wszCLSID)/sizeof(wszCLSID[0]));
HRESULT hr = StringCchPrintf(wszMonikerName, sizeof(wszMonikerName)/sizeof(wszMonikerName[0]), L"Elevation:Administrator!new:%s", wszCLSID);
if (FAILED(hr))
return hr;
memset(&bo, 0, sizeof(bo));
bo.cbStruct = sizeof(bo);
bo.hwnd = hwnd;
bo.dwClassContext = CLSCTX_LOCAL_SERVER;
return CoGetObject(wszMonikerName, &bo, riid, ppv);
}
i just cant get the code to work, it will be running from an injected dll if that makes a difference