objectCreate Schedule.Service

Started by CadJoe, November 17, 2014, 02:45:19 PM

Previous topic - Next topic

CadJoe

I was playing with this on 2014A:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/Task~Scheduler+Create~Task~Run~as~SYSTEM.txt

And I get a COM/CLR: Exception on the last line to Register the task.

rootFolder.RegisterTaskDefinition( "RunNotePad", taskDefinition, 6, userid , password , 3)


I noticed you had great comments on most lines of code, but nothing on this line.

Any idea why I might be getting the COM/CLR Exception error?

Thanks,

CadJoe
WinBatch, Gotta Love It!


td

Follow the link in the article.  Check the parameters you are using for the 'RegisterTaskDefinition' member of the taskFolder object against the documentation for the method's parameter.  Make sure they are correct. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

ugh, its because it isn't elevated.

I ran the same Winbatch from an elevated dos prompt, and it created the Task just fine.

I thought this was a way around needing elevation, was to schedule it as a system task with highest privileges.

Thanks,

CadJoe
WinBatch, Gotta Love It!

td

Good catch.  The script will allow you to create a way to run applications without the elevation prompt.  You can do that by creating a shortcut to the task scheduler on the desktop with your newly minted task as the argument to the /tn option.  However, creating the task in the first place does, as you discovered, require elevation.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

So is there any way at all that a Winbatch can elevate a task?

Maybe a future need for a UAC extender?

Thanks,

CadJoe
WinBatch, Gotta Love It!

td

Quote from: CadJoe on November 18, 2014, 07:22:05 AM
So is there any way at all that a Winbatch can elevate a task?

If by task you mean starting a process, then yes, start the process from an elevated WinBatch process.  You can also use the Task Scheduler trick on Windows 7 or the App Compatibility tool kit on Windows 7 and beyond.

Quote
Maybe a future need for a UAC extender?

Very, very unlikely.  MSFT went to a lot of work to prevent the circumvention of UAC and with the above exceptions they have more or less succeeded.  UAC has been around since 2007, is now generally accepted and isn't going away.  Basically their view is that if you think you need to circumvent UAC there is something wrong with your design. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

Ok, thinking we are going to create a run_once system scheduled task in all of our images that points to a Run_Once.CMD file.

Since the CMD is just a text file that is not stored in any system folders, we can remotely change it easily without elevation.

Then anything we want to run elevated, we remotely run the scheduled task.

Thanks,

CadJoe
WinBatch, Gotta Love It!

td

Interesting approach.  I assume you have already considered and rejected using login scripts since they run before UAC is in effect on Windows 7.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade