ThinkPaper
asked on
PsExec - Create Task in Task Scheduler; How to fix this command?
Hey experts
I need some help trying to come up with the proper command for this.
I have a long list of servers, which I need to create a task on for each to archive their event logs. I've created a vbscript to do the actual archiving, but now need to hook it up with the Task Scheduler. The code I have so far is:
psexec \\computer1 -u domain/Admin -p Passwd schtasks /create /tn "ArchiveLog" /tr "c:/task/ArchiveLog.vbs" \\T:3600 /sc DAILY /ru MYDOMAIN/backmeup /rp Password
This creates a task successfully, but it is still not configured the way I want it to be. Doing it this way, when you open the task properties, it ends up looking like picture 1. I want it to look like picture 2. How do you modify the command above so that it looks like Picture 2?
The reason being is that vbs on all the machines (for security reasons) is configured to not automatically run (it actually executes as a text file) - so I need to attach the cscript.exe along with the vbs file to make sure it actually runs properly..
ex:
run this: cscript ArchiveLog.vbs
instead of just this: ArchiveLog.vbs
taskscheduler1.bmp
taskscheduler2.bmp
I need some help trying to come up with the proper command for this.
I have a long list of servers, which I need to create a task on for each to archive their event logs. I've created a vbscript to do the actual archiving, but now need to hook it up with the Task Scheduler. The code I have so far is:
psexec \\computer1 -u domain/Admin -p Passwd schtasks /create /tn "ArchiveLog" /tr "c:/task/ArchiveLog.vbs" \\T:3600 /sc DAILY /ru MYDOMAIN/backmeup /rp Password
This creates a task successfully, but it is still not configured the way I want it to be. Doing it this way, when you open the task properties, it ends up looking like picture 1. I want it to look like picture 2. How do you modify the command above so that it looks like Picture 2?
The reason being is that vbs on all the machines (for security reasons) is configured to not automatically run (it actually executes as a text file) - so I need to attach the cscript.exe along with the vbs file to make sure it actually runs properly..
ex:
run this: cscript ArchiveLog.vbs
instead of just this: ArchiveLog.vbs
taskscheduler1.bmp
taskscheduler2.bmp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No need for psexec.
schtasks /create /s computer1 /u domain/Admin /p Passwd /tn "ArchiveLog" /tr "cscript C:\task\ArchiveLog.vbs \\T:3600" /sc DAILY /ru MYDOMAIN/backmeup /rp Password
To determine the quote was out of place, I used the schtasks without the psexec.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks you're right.. the slashes are wrong but that wasn't the problem (typo again aghh)
the reason for the psexec was so that i can create tasks remotely for multiple machines:
psexec \\computer1,computer2,comp uter3 /u domain\Admin /p Passwd schtasks /create /tn "ArchiveLog" /tr "cscript C:\task\ArchiveLog.vbs \\T:3600" /sc DAILY /ru MYDOMAIN\backmeup /rp Password
is there a way to create the task on multiple machines without psexec?
the reason for the psexec was so that i can create tasks remotely for multiple machines:
psexec \\computer1,computer2,comp
is there a way to create the task on multiple machines without psexec?
Put your computers into a text file 1 per line.
The file computers.txt
computer1
computer2
computer3
The file computers.txt
computer1
computer2
computer3
for /f %%c in (Computers.txt) do (
schtasks /create /s %%c /u domain\Admin /p Passwd /tn "ArchiveLog" /tr "cscript C:\task\ArchiveLog.vbs \\T:3600" /sc DAILY /ru MYDOMAIN\backmeup /rp Password
)
ASKER
got it thanks.. I was actually asking if there was a way to bypass the psexec through task scheduler. Didn't want to complicate it further by scripting more stuff.. so for this instance psexec works fine with this... =) (PsExec actually got it's own way of doing 'batch stuff' by using the @computer.txt file so you don't need to create a for loop)
psexec @computerlist.txt -u domain/Admin -p password schtasks /create /tn "ArchiveLog" /tr "cscript C:\task\ArchiveLog.vbs \\T:3600" /sc DAILY /ru MYDOMAIN\backmeup /rp Password
psexec @computerlist.txt -u domain/Admin -p password schtasks /create /tn "ArchiveLog" /tr "cscript C:\task\ArchiveLog.vbs \\T:3600" /sc DAILY /ru MYDOMAIN\backmeup /rp Password
ASKER
cscript ArchiveLog.vbs
I need to run it together - I cant just execute the vbs by itself bc it won't just run.