|
|
|
|
@ -14,7 +14,7 @@ type elevatedOptions struct {
|
|
|
|
|
|
|
|
|
|
var elevatedTemplate = template.Must(template.New("ElevatedCommand").Parse(`
|
|
|
|
|
$name = "{{.TaskName}}"
|
|
|
|
|
$log = "$env:TEMP\$name.out"
|
|
|
|
|
$log = "$env:SystemRoot\Temp\$name.out"
|
|
|
|
|
$s = New-Object -ComObject "Schedule.Service"
|
|
|
|
|
$s.Connect()
|
|
|
|
|
$t = $s.NewTask($null)
|
|
|
|
|
@ -53,7 +53,7 @@ $t.XmlText = @'
|
|
|
|
|
<Actions Context="Author">
|
|
|
|
|
<Exec>
|
|
|
|
|
<Command>cmd</Command>
|
|
|
|
|
<Arguments>/c powershell.exe -EncodedCommand {{.EncodedCommand}} > %TEMP%\{{.TaskName}}.out 2>&1</Arguments>
|
|
|
|
|
<Arguments>/c powershell.exe -EncodedCommand {{.EncodedCommand}} > %SYSTEMROOT%\Temp\{{.TaskName}}.out 2>&1</Arguments>
|
|
|
|
|
</Exec>
|
|
|
|
|
</Actions>
|
|
|
|
|
</Task>
|
|
|
|
|
@ -81,5 +81,8 @@ do {
|
|
|
|
|
}
|
|
|
|
|
} while (!($t.state -eq 3))
|
|
|
|
|
$result = $t.LastTaskResult
|
|
|
|
|
if (Test-Path $log) {
|
|
|
|
|
Remove-Item $log -Force -ErrorAction SilentlyContinue | Out-Null
|
|
|
|
|
}
|
|
|
|
|
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($s) | Out-Null
|
|
|
|
|
exit $result`))
|
|
|
|
|
|