Reputation: 721
When I Create Scheduler Task with the Username and Password in Windows 7 using Task Scheduler GUI and trying to Change the Password of User using Following Command line, it give me error in CMD
SCHTASKS /Change /RP test /TN "rtest1"
Error:
The Parameter is incorrect
Upvotes: 0
Views: 18613
Reputation: 721
I Found the Following Solution for my Question, I want to Share it with you all.
I created a scheduled task like suggested above
schtasks.exe /create /S remotemgmt /tn "Mytask" /tr "mspaint" /u admuser /p PassWord /sc "Monthly"/st "13:00" /F
Then I created MyTask2 from the GUI, mirroring all the settings of the task created by schtasks
If I do:
schtasks.exe /change /S remotemgmt /tn "Mytask" /Ru domain\UberUser /Rp PassWord
That works as expected
If I try to run the same on MyTask2 it fails with the above mentioned error
schtasks.exe /change /S remotemgmt /tn "Mytask2" /Ru domain\UberUser /Rp PassWord
One thing I noticed is that if I export the XML files, from MyTask and MyTask2 is that they are different, even though all the settings you can see in the GUI are the same.
The problem seems to be in the tag:
If I created a task from the commandline and export it it looks like this: 2010-12-06T13:00:00
If I create/export it from the GUI i looks like this: 2010-12-06T22:13:59.9965698
If I open the exported XML file, and deletes .9965698 save the file, Re Import it into Scheduled tasks
"schtasks.exe /change /S remotemgmt /tn "Mytask2" /Ru domain\UberUser /Rp PassWord" works
There are other differences in the XML files as well, it seems that when you create tasks using schtasks some timespans are written in Hours, whereas if I create it in the GUI it is in days.
GUI : P3D
CLI: PT72H
These two are not set, when using the GUI to create the task:
PT10M PT1H
These do however not affect the ability to change the settings afterwards with schtasks.exe.
Upvotes: 4
Reputation: 639
You can use the PowerShell script to update scheduled task credentials, which Bill Steward has written for this purpose (thanks a lot to him). This works also for tasks, which were created with the Windows task scheduler GUI and not from command line (or reimported or such). The webpage has all the explanations and example usage.
Note that you may need to run set-executionpolicy unrestricted
in the powershell shell first to allow execution of the script.
Upvotes: 1
Reputation: 41
For future troubleshooting, after the below steps failed me, I tried some additional tweaking and found that for me, I was unable to get my schtasks password change to work until I imported the XML less the Repetition portion of the XML, (i.e. the PT10M interval and the P1D duration). After I imported the XML without those pieces, I was able to go into the GUI and make those changes there. Afterwards, Schtasks worked for me to change the password. Bizarre behavior!!
Upvotes: 4