Jump to content
Sign in to follow this  
Raffav

Edit a task scheduler xml

Recommended Posts

Raffav

Hello

I need some help how to edit the task scheduler xml

here is the xml

<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2014-01-02T09:36:49.105327</Date>
    <Author>ANSWER\raffaello</Author>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2014-01-02T14:00:00Z</StartBoundary>
      <ExecutionTimeLimit>PT2H</ExecutionTimeLimit>
      <Enabled>true</Enabled>
      <RandomDelay>PT30M</RandomDelay>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>ANSWER\raffaello</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\Users\raffaello\Documents\Arquivos do Outlook\pst check test\PST_CHECK_V2.5_X86.EXE"</Command>
      <Arguments>mon</Arguments>
      <WorkingDirectory>C:\Users\raffaello\Documents\Arquivos do Outlook\pst check test</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

I need for example to edit Author info in </RegistrationInfo>

i am trying with the  _XMLDomWrapper.au3 udf

this is the code that i was starting to test it but no success, i cant figured out how to do it 

#include "_XMLDomWrapper.au3"
#include <Array.au3>
$xmlteste = "2pst_check.xml"
$strXPath = "/Task/RegistrationInfo/Author"
$rt = _XMLFileOpen($xmlteste,'xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"')
If @error Then
ConsoleWrite("exmple.xml " & _XMLError("") & @CRLF)
Exit
EndIf
MsgBox(0, "asd", $rt)

;~  $rt2= _XMLCreateFile($xmlteste,"Settings", True)
;~  MsgBox(0,"asd",$rt2)
;~  _XMLCreateRootNodeWAttr ("Position", "a123", "2345")
;~  _XMLCreateRootChild ("Author", "teste23")
$rt3 = _XMLCreateChildNode("RegistrationInfo", "Author", "asdf")
;~ $rt3 =  _XMLUpdateField($strXPath, "teste")

If @error Then
ConsoleWrite("exmple.xml " & _XMLError("") & @CRLF)
Exit
EndIf
;~ MsgBox(0, "asd", $rt3)
;~ _ConvertFileToUTF16($xmlteste)

Func _ConvertFileToUTF16($sFilePath)
Local $iEncoding = FileGetEncoding($sFilePath)
Local $hFileOpen = FileOpen($sFilePath, $iEncoding)
If $hFileOpen = -1 Then
Return SetError(1, 0, 0)
EndIf
Local $sData = FileRead($hFileOpen)
FileClose($hFileOpen)

$hFileOpen = FileOpen($sFilePath, 2 + 32)
If $hFileOpen = -1 Then
Return SetError(2, 0, 0)
EndIf
FileWrite($hFileOpen, $sData)
Return FileClose($hFileOpen)
EndFunc   ;==>_ConvertFileToUTF16

 

Thanks

for any help

sorry for bad English 

Edited by Raffav

Share this post


Link to post
Share on other sites
jdelaney

Something like this ...use $oxml.save to save the new file (or overwrite the current)...google it for the syntax:

$sLocalXMLFile = @DesktopDir & "\xml.xml"
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($sLocalXMLFile)

; Check if node exists:
$oCheck = $oXML.selectSingleNode("//RegistrationInfo/Author")
If IsObj($oCheck) Then
    ; If exists, change the value
    $oCheck.text = "asdf"
Else
    ; If not exists, create, and then append
    $oAuthor = $oXML.createElement("Author")
    $oAuthor.text = "asdf"

    $oParent = $oXML.selectSingleNode("//RegistrationInfo")
    $oParent.appendChild ($oAuthor)
EndIf

ConsoleWrite($oXML.xml)
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Raffav

 

Something like this ...use $oxml.save to save the new file (or overwrite the current)...google it for the syntax:

$sLocalXMLFile = @DesktopDir & "\xml.xml"
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($sLocalXMLFile)

; Check if node exists:
$oCheck = $oXML.selectSingleNode("//RegistrationInfo/Author")
If IsObj($oCheck) Then
    ; If exists, change the value
    $oCheck.text = "asdf"
Else
    ; If not exists, create, and then append
    $oAuthor = $oXML.createElement("Author")
    $oAuthor.text = "asdf"

    $oParent = $oXML.selectSingleNode("//RegistrationInfo")
    $oParent.appendChild ($oAuthor)
EndIf

ConsoleWrite($oXML.xml)

Thanks for quicker answer

i will give a try 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×