Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c6f66c6b
Commit
c6f66c6b
authored
Jan 19, 2018
by
Jacek Caban
Committed by
Alexandre Julliard
Jan 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
schtasks: Added /delete command implementation.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1246a277
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
11 deletions
+79
-11
schtasks.c
programs/schtasks/schtasks.c
+77
-10
schtasks.c
programs/schtasks/tests/schtasks.c
+2
-1
No files found.
programs/schtasks/schtasks.c
View file @
c6f66c6b
...
@@ -26,17 +26,17 @@
...
@@ -26,17 +26,17 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
schtasks
);
WINE_DEFAULT_DEBUG_CHANNEL
(
schtasks
);
const
WCHAR
change_optW
[]
=
{
'/'
,
'c'
,
'h'
,
'a'
,
'n'
,
'g'
,
'e'
,
0
};
static
const
WCHAR
change_optW
[]
=
{
'/'
,
'c'
,
'h'
,
'a'
,
'n'
,
'g'
,
'e'
,
0
};
const
WCHAR
enable_optW
[]
=
{
'/'
,
'e'
,
'n'
,
'a'
,
'b'
,
'l'
,
'e'
,
0
};
static
const
WCHAR
delete_optW
[]
=
{
'/'
,
'd'
,
'e'
,
'l'
,
'e'
,
't'
,
'e'
,
0
};
const
WCHAR
tn_optW
[]
=
{
'/'
,
't'
,
'n'
,
0
};
static
const
WCHAR
enable_optW
[]
=
{
'/'
,
'e'
,
'n'
,
'a'
,
'b'
,
'l'
,
'e'
,
0
};
static
const
WCHAR
f_optW
[]
=
{
'/'
,
'f'
,
0
};
static
const
WCHAR
tn_optW
[]
=
{
'/'
,
't'
,
'n'
,
0
};
static
I
RegisteredTask
*
get_registered_task
(
const
WCHAR
*
name
)
static
I
TaskFolder
*
get_tasks_root_folder
(
void
)
{
{
IRegisteredTask
*
registered_task
;
ITaskService
*
service
;
ITaskService
*
service
;
ITaskFolder
*
folder
;
ITaskFolder
*
root
;
VARIANT
empty
;
VARIANT
empty
;
BSTR
str
;
HRESULT
hres
;
HRESULT
hres
;
hres
=
CoCreateInstance
(
&
CLSID_TaskScheduler
,
NULL
,
CLSCTX_INPROC_SERVER
,
hres
=
CoCreateInstance
(
&
CLSID_TaskScheduler
,
NULL
,
CLSCTX_INPROC_SERVER
,
...
@@ -51,17 +51,31 @@ static IRegisteredTask *get_registered_task(const WCHAR *name)
...
@@ -51,17 +51,31 @@ static IRegisteredTask *get_registered_task(const WCHAR *name)
return
NULL
;
return
NULL
;
}
}
hres
=
ITaskService_GetFolder
(
service
,
NULL
,
&
folder
);
hres
=
ITaskService_GetFolder
(
service
,
NULL
,
&
root
);
ITaskService_Release
(
service
);
ITaskService_Release
(
service
);
if
(
FAILED
(
hres
))
{
if
(
FAILED
(
hres
))
{
FIXME
(
"GetFolder failed: %08x
\n
"
,
hres
);
FIXME
(
"GetFolder failed: %08x
\n
"
,
hres
);
return
NULL
;
return
NULL
;
}
}
return
root
;
}
static
IRegisteredTask
*
get_registered_task
(
const
WCHAR
*
name
)
{
IRegisteredTask
*
registered_task
;
ITaskFolder
*
root
;
BSTR
str
;
HRESULT
hres
;
root
=
get_tasks_root_folder
();
if
(
!
root
)
return
NULL
;
str
=
SysAllocString
(
name
);
str
=
SysAllocString
(
name
);
hres
=
ITaskFolder_GetTask
(
folder
,
str
,
&
registered_task
);
hres
=
ITaskFolder_GetTask
(
root
,
str
,
&
registered_task
);
SysFreeString
(
str
);
SysFreeString
(
str
);
ITaskFolder_Release
(
folder
);
ITaskFolder_Release
(
root
);
if
(
FAILED
(
hres
))
{
if
(
FAILED
(
hres
))
{
FIXME
(
"GetTask failed: %08x
\n
"
,
hres
);
FIXME
(
"GetTask failed: %08x
\n
"
,
hres
);
return
NULL
;
return
NULL
;
...
@@ -118,6 +132,57 @@ static int change_command(int argc, WCHAR *argv[])
...
@@ -118,6 +132,57 @@ static int change_command(int argc, WCHAR *argv[])
return
0
;
return
0
;
}
}
static
int
delete_command
(
int
argc
,
WCHAR
*
argv
[])
{
const
WCHAR
*
task_name
=
NULL
;
ITaskFolder
*
root
=
NULL
;
BSTR
str
;
HRESULT
hres
;
while
(
argc
)
{
if
(
!
strcmpiW
(
argv
[
0
],
f_optW
))
{
TRACE
(
"force opt
\n
"
);
argc
--
;
argv
++
;
}
else
if
(
!
strcmpiW
(
argv
[
0
],
tn_optW
))
{
if
(
argc
<
2
)
{
FIXME
(
"Missing /tn value
\n
"
);
return
1
;
}
if
(
task_name
)
{
FIXME
(
"Duplicated /tn argument
\n
"
);
return
1
;
}
task_name
=
argv
[
1
];
argc
-=
2
;
argv
+=
2
;
}
else
{
FIXME
(
"Unsupported argument %s
\n
"
,
debugstr_w
(
argv
[
0
]));
return
1
;
}
}
if
(
!
task_name
)
{
FIXME
(
"Missing /tn argument
\n
"
);
return
1
;
}
root
=
get_tasks_root_folder
();
if
(
!
root
)
return
1
;
str
=
SysAllocString
(
task_name
);
hres
=
ITaskFolder_DeleteTask
(
root
,
str
,
0
);
SysFreeString
(
str
);
ITaskFolder_Release
(
root
);
if
(
FAILED
(
hres
))
return
1
;
return
0
;
}
int
wmain
(
int
argc
,
WCHAR
*
argv
[])
int
wmain
(
int
argc
,
WCHAR
*
argv
[])
{
{
int
i
,
ret
=
0
;
int
i
,
ret
=
0
;
...
@@ -132,6 +197,8 @@ int wmain(int argc, WCHAR *argv[])
...
@@ -132,6 +197,8 @@ int wmain(int argc, WCHAR *argv[])
FIXME
(
"Print current tasks state
\n
"
);
FIXME
(
"Print current tasks state
\n
"
);
else
if
(
!
strcmpiW
(
argv
[
1
],
change_optW
))
else
if
(
!
strcmpiW
(
argv
[
1
],
change_optW
))
ret
=
change_command
(
argc
-
2
,
argv
+
2
);
ret
=
change_command
(
argc
-
2
,
argv
+
2
);
else
if
(
!
strcmpiW
(
argv
[
1
],
delete_optW
))
ret
=
delete_command
(
argc
-
2
,
argv
+
2
);
else
else
FIXME
(
"Unsupported command %s
\n
"
,
debugstr_w
(
argv
[
1
]));
FIXME
(
"Unsupported command %s
\n
"
,
debugstr_w
(
argv
[
1
]));
...
...
programs/schtasks/tests/schtasks.c
View file @
c6f66c6b
...
@@ -180,7 +180,8 @@ START_TEST(schtasks)
...
@@ -180,7 +180,8 @@ START_TEST(schtasks)
r
=
run_command
(
"schtasks /CHANGE /tn wine
\\
test
\\
winetest /enable"
);
r
=
run_command
(
"schtasks /CHANGE /tn wine
\\
test
\\
winetest /enable"
);
ok
(
r
==
0
,
"r = %u
\n
"
,
r
);
ok
(
r
==
0
,
"r = %u
\n
"
,
r
);
unregister_task
(
"wine
\\
test
\\
winetest"
);
r
=
run_command
(
"schtasks /delete /f /tn wine
\\
test
\\
winetest"
);
ok
(
r
==
0
,
"r = %u
\n
"
,
r
);
r
=
run_command
(
"schtasks /Change /tn wine
\\
test
\\
winetest /enable"
);
r
=
run_command
(
"schtasks /Change /tn wine
\\
test
\\
winetest /enable"
);
ok
(
r
==
1
,
"r = %u
\n
"
,
r
);
ok
(
r
==
1
,
"r = %u
\n
"
,
r
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment