调用windows计划任务IRegisteredTask的run函数传参失败
API定义如下:
Run Method of the IRegisteredTask Interface
Runs the registered task immediately.
HRESULT Run(
[in] VARIANT params,
[out, optional] IRunningTask** ppRunningTask
);
为了规避UAC,我在程序中调用了计划任务以提高自身权限,其中需要调用IRegisteredTask 的run函数,我试图给run函数传递命令行,但是新启动的程序并未收到我传的命令行参数。跪求大神帮忙解答。
我的程序如下:
Run(LPCTSTR lpszParam)
{
if (m_pRootFolder == NULL)
{
LOG4C_DEBUG(L"[Run] m_pRootFolder NULL");
return FALSE;
}
HRESULT hr = S_OK;
CComVariant variant(NULL);
variant = m_strTaskName.c_str();
CComPtr<IRegisteredTask> pRegisteredTask;
hr = m_pRootFolder->GetTask(variant.bstrVal,&pRegisteredTask);
if (FAILED(hr) || pRegisteredTask == NULL)
{
LOG4C_DEBUG(L"[Run] GetTask FAILED");
return FALSE;
}
CComVariant varPar(NULL);
varPar = lpszParam;
hr = pRegisteredTask->Run(varPar,NULL);
//LOG4C_DEBUG(L"[Run] varPar=%s",varPar.bstrVal);
if (FAILED(hr))
{
LOG4C_DEBUG(L"[Run] Release FAILED");
return FALSE;
}
return TRUE;
}