Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PsExec - Create Task in Task Scheduler; How to fix this command?

Posted on 2009-02-18
8
Medium Priority
?
3,555 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:ThinkPaper
  • 3
  • 3
  • 2
8 Comments
 
LVL 6

Assisted Solution

by:Jammer59
Jammer59 earned 200 total points
ID: 23675119
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
 
LVL 16

Author Comment

by:ThinkPaper
ID: 23675268
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
 
LVL 21

Expert Comment

by:AmazingTech
ID: 23675488
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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 6

Expert Comment

by:Jammer59
ID: 23675540
To determine the quote was out of place, I used the schtasks without the psexec.  
0
 
LVL 21

Accepted Solution

by:
AmazingTech earned 1800 total points
ID: 23675653
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
 
LVL 16

Author Comment

by:ThinkPaper
ID: 23676120
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
 
LVL 21

Expert Comment

by:AmazingTech
ID: 23676881
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
 
LVL 16

Author Closing Comment

by:ThinkPaper
ID: 31548607
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question