Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Execute a schedule task from a remote Server

Posted on 2004-10-29
Medium Priority
Last Modified: 2010-07-27
How do you execute a scheduled task from a remote server?
Can you do in WMI Service?
Question by:Paul_Schroeder
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 11

Expert Comment

ID: 12446355
Do you mean that you have a task scheduled to start at some time, but you want to run it NOW activating it from a remote server?
you want to schedule a new task from a remote server?

Author Comment

ID: 12446459
No, what I want to do is not to have a particular schedule, but execute from a vbscript or via WMI service.  I was able to schedule a new task remotely with WMI Service, but I am having problems getting the right time value because it is the UTC date.  Also I when creating the task it would not set the runas or password so it would not run.

The bottom line is:  I would like to be able to execute a .vbs script on a remote server somehow.  That is what I am trying to do.  If you know a way to do it that would be great.

I tryed doing using the WMI Service but I could not get the script to run doing the createProcess, but the schedule task would work.  Here is the script that I am testing.

Function Main()

dim objAccessApp,process
dim objWMIService,objStartup,objConfig
dim StrComputer,strSec,strHour,strMin

strComputer = "AAA93"

if len(hour(now)) = 1 then
  strHour = "0" & hour(now)
  strHour = hour(now)
end if

if len(minute(now)) = 1 then
  strMin = "0" & (Cint(Minute(now)) + 1)
  strMin = Cint(Minute(now)) + 1
end if

if len(second(now)) = 1 then
  strSec = "0" & second(now)
  strSec = Second(now)
end if

Set objwmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objwmiService = objwmiLocator.ConnectServer("AAA93" , "root\cimv2", "user", "password", , , iSecurityFlags = 128)
objwmiLocator.Security_.ImpersonationLevel = 3

'Set objStartup = objWMIService.Get("Win32_ProcessStartup")
'Set objConfig = objStartup.SpawnInstance_

Set objNewJob = objWMIService.Get("Win32_ScheduledJob")

schTime = "********" & strHour & StrMin & strSec & ".000000-000"

errJobCreated = objNewJob.Create("C:\Config\rptDentaMax.vbs", schTime, False , , , True, JobID)

'Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")

'errReturn = objProcess.Create("\Config\rptDentamax.vbs", null,objConfig, intProcessID)

Set fso = CreateObject("Scripting.FileSystemObject")
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    log_location = "\\AAA93\Config\NEW"
    Set errors = fso.OpenTextFile(log_location & "_diskrpt_wmi_exceptions.log", ForWriting, True)

Main = DTSTaskExecResult_Success

End Function  

The bott
LVL 11

Expert Comment

ID: 12446657
Using the "schtasks" you can specify user/password. Is this good enough?
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 12446699

How do you set the user/Password?  What is "schtasks" is it a different object?
If I can set the user/password that would  be good.
LVL 11

Expert Comment

ID: 12446772
No sorry this is a command line tool available in windows xp (I'm not sure if it's available in 2k too).
Type "schtasks /create /?" from the command line for more info
LVL 11

Accepted Solution

pratap_r earned 2000 total points
ID: 12447677
hey Paul

just try executing the process using cscript and pass the vb script as parameter to it rather than directly executing the script.

and as for trying on the remote machine.. AT command should work fine.. it can trigger & schedule jobs on the target machine.. as long as you have rights on it..

Have fun
LVL 11

Expert Comment

ID: 12827139
lbertacco's solution works fine on xp machine.. my solution was a generic one..

a split would be a good option

Have Fun!

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

636 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