Commit a5af50c5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

schtasks: Added partial /change command implementation.

This is needed by Office 2016 installer. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 8f35b20a
MODULE = schtasks.exe
APPMODE = -mconsole -municode
IMPORTS = oleaut32 ole32
C_SRCS = \
schtasks.c
......@@ -16,18 +16,125 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "initguid.h"
#include "taskschd.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(schtasks);
const WCHAR change_optW[] = {'/','c','h','a','n','g','e',0};
const WCHAR enable_optW[] = {'/','e','n','a','b','l','e',0};
const WCHAR tn_optW[] = {'/','t','n',0};
static IRegisteredTask *get_registered_task(const WCHAR *name)
{
IRegisteredTask *registered_task;
ITaskService *service;
ITaskFolder *folder;
VARIANT empty;
BSTR str;
HRESULT hres;
hres = CoCreateInstance(&CLSID_TaskScheduler, NULL, CLSCTX_INPROC_SERVER,
&IID_ITaskService, (void**)&service);
if (FAILED(hres))
return NULL;
V_VT(&empty) = VT_EMPTY;
hres = ITaskService_Connect(service, empty, empty, empty, empty);
if (FAILED(hres)) {
FIXME("Connect failed: %08x\n", hres);
return NULL;
}
hres = ITaskService_GetFolder(service, NULL, &folder);
ITaskService_Release(service);
if (FAILED(hres)) {
FIXME("GetFolder failed: %08x\n", hres);
return NULL;
}
str = SysAllocString(name);
hres = ITaskFolder_GetTask(folder, str, &registered_task);
SysFreeString(str);
ITaskFolder_Release(folder);
if (FAILED(hres)) {
FIXME("GetTask failed: %08x\n", hres);
return NULL;
}
return registered_task;
}
static int change_command(int argc, WCHAR *argv[])
{
const WCHAR *task_name;
IRegisteredTask *task;
HRESULT hres;
if (!argc) {
FIXME("Missing /tn option\n");
return 1;
}
if (strcmpiW(argv[0], tn_optW)) {
FIXME("Unsupported %s option\n", debugstr_w(argv[0]));
return 0;
}
if (argc < 2) {
FIXME("Missing /tn value\n");
return 1;
}
task_name = argv[1];
argc -= 2;
argv += 2;
if (!argc) {
FIXME("Missing change options\n");
return 1;
}
if (strcmpiW(argv[0], enable_optW) || argc > 1) {
FIXME("Unsupported arguments %s\n", debugstr_w(argv[0]));
return 0;
}
task = get_registered_task(task_name);
if (!task)
return 1;
hres = IRegisteredTask_put_Enabled(task, VARIANT_TRUE);
IRegisteredTask_Release(task);
if (FAILED(hres)) {
FIXME("put_Enabled failed: %08x\n", hres);
return 1;
}
return 0;
}
int wmain(int argc, WCHAR *argv[])
{
int i;
int i, ret = 0;
WINE_FIXME("stub:");
for (i = 0; i < argc; i++)
WINE_FIXME(" %s", wine_dbgstr_w(argv[i]));
WINE_FIXME("\n");
TRACE(" %s", wine_dbgstr_w(argv[i]));
TRACE("\n");
return 0;
CoInitialize(NULL);
if (argc < 2)
FIXME("Print current tasks state\n");
else if (!strcmpW(argv[1], change_optW))
ret = change_command(argc - 2, argv + 2);
else
FIXME("Unsupported command %s\n", debugstr_w(argv[1]));
CoUninitialize();
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment