Jump to content
Sign in to follow this  
cntour

how to use runas to create scheduled task on local machine

Recommended Posts

cntour

I need to create scheduled task with administrative privilege locally:

For example, PC1 is logged on by regular user who doesn't have administrative right, if he run the program I give him, he can add scheduled task on his machine.

Local $sUserName = "administrator"

Local $sPassword = "admin_password"

local $sDomain=@ComputerName

local $sProgram = "schtasks /create /RU administrator /RP ""admin_password"" /sc Weekly /D MON /tn ""sdsystem"" /tr ""shutdown -f -s -t 600 "" /ST 05:30:00"

runas($sUserName,$sDomain,$sPassword,0, $sProgram)

it doesn't work. Could you give me some advice?

Thanks a lot.

Share this post


Link to post
Share on other sites
cntour

Could I go back to use runasset instead of runas in the new version?

TY.

Share this post


Link to post
Share on other sites
PsaltyDS

Could I go back to use runasset instead of runas in the new version?

TY.

What difference would that make?

Did you try providing the full path to SchTasks.exe in your command line, and a working Dir parameter?

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×