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
LVL 16
ThinkPaperIT ConsultantAsked:
Who is Participating?
 
AmazingTechCommented:
I think the slashes for user should be with a \ not /.
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

Open in new window

0
 
Jammer59Commented:
A misplaced quote I believe.  Change the items in bold from:
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
to
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
0
 
ThinkPaperIT ConsultantAuthor Commented:
oops typo.. but same issue.. how do I include this phrase as the actual task??

cscript ArchiveLog.vbs

I need to run it together - I cant just execute the vbs by itself bc it won't just run.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
AmazingTechCommented:
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

Open in new window

0
 
Jammer59Commented:
To determine the quote was out of place, I used the schtasks without the psexec.  
0
 
ThinkPaperIT ConsultantAuthor Commented:
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,computer3 /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?
0
 
AmazingTechCommented:
Put your computers into a text file 1 per line.

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
)

Open in new window

0
 
ThinkPaperIT ConsultantAuthor Commented:
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
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.