locked
How to run a vbs file using task scheduler?

    السؤال

  • Hi,

    I am trying to create a task (in task scheduler) to execute a vbscript file. The vbs file execute from the run command, but not using the task created. The vbs file contains only a simple test statment - MsgBos "Hello". i also tried giving full command "cscript ..\test.vbs" in the task scheduler. But not working. Can anybody please comment?

    regards,

    Jimmy

     

     

    16/جمادى الأولى/1431 06:47 ص

الإجابات

  • A VB script can run directly from Windows task schedule.  In the task scheduler,  select Add a new scheduled task.  Following the prompts, browse to select your .vbs file.  Name your task and select your schedule to run the task daily and select the time of day to run.  It works just the same as if you want to schedule .Bat file.

    Use the absolute file path in the command. 

    Or call vbs file from a .bat file.

    cscript //nologo c:\test.vbs


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX http://blogs.sivarajan.com/ http://publications.sivarajan.com/ This posting is provided "AS IS" with no warranties, and confers no rights.
    • تم وضع علامة كإجابة بواسطة Bruce-Liu 19/جمادى الأولى/1431 10:59 ص
    16/جمادى الأولى/1431 04:12 م
  • Hi,

    I am trying to create a task (in task scheduler) to execute a vbscript file. The vbs file execute from the run command, but not using the task created. The vbs file contains only a simple test statment - MsgBos "Hello". i also tried giving full command "cscript ..\test.vbs" in the task scheduler. But not working. Can anybody please comment?

    regards,

    Jimmy

     

     

    Run a batch file

    wscript or cscript, whichever your preference is to get the objective accomplished.

    If you use the task to execute a batch script, the batch script will even propose options to log each success of executing this script for you. If you're not familiar with creating batch files, it allows you to execute a string of commands as if you were there. Obviously it takes some trial and error to get the batch file to behave the way you want it to but... in this case...

    Open Notepad, enter your command... 

    cscript <dir>\test.vbs

    Then save this notepad document to a system directory that is easy to remember, like "C:\Scripts" or "C:\Windows\Scripts\" with a .BAT file extension.

    As far as I've experienced, there's been no issues getting batch files to execute. Just make sure you issue CD before hand or use the full file path. Typically it will execute as the system user unless you specify an account, which is not the default path for users.

     

    I hope this resolves your issues,

    Good Luck

    -Steve Kline - MCTS: Cfg. Srv 2K8 AD; Cfg. Srv 2K8 NI


    Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they do not understand. - Archibald Putt's (Putt's Law)
    • تم الاقتراح كإجابة بواسطة Steve Kline 16/جمادى الأولى/1431 02:05 م
    • تم وضع علامة كإجابة بواسطة Bruce-Liu 19/جمادى الأولى/1431 10:59 ص
    16/جمادى الأولى/1431 02:04 م

جميع الردود

  • Hi,

    I am trying to create a task (in task scheduler) to execute a vbscript file. The vbs file execute from the run command, but not using the task created. The vbs file contains only a simple test statment - MsgBos "Hello". i also tried giving full command "cscript ..\test.vbs" in the task scheduler. But not working. Can anybody please comment?

    regards,

    Jimmy

     

     

    Run a batch file

    wscript or cscript, whichever your preference is to get the objective accomplished.

    If you use the task to execute a batch script, the batch script will even propose options to log each success of executing this script for you. If you're not familiar with creating batch files, it allows you to execute a string of commands as if you were there. Obviously it takes some trial and error to get the batch file to behave the way you want it to but... in this case...

    Open Notepad, enter your command... 

    cscript <dir>\test.vbs

    Then save this notepad document to a system directory that is easy to remember, like "C:\Scripts" or "C:\Windows\Scripts\" with a .BAT file extension.

    As far as I've experienced, there's been no issues getting batch files to execute. Just make sure you issue CD before hand or use the full file path. Typically it will execute as the system user unless you specify an account, which is not the default path for users.

     

    I hope this resolves your issues,

    Good Luck

    -Steve Kline - MCTS: Cfg. Srv 2K8 AD; Cfg. Srv 2K8 NI


    Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they do not understand. - Archibald Putt's (Putt's Law)
    • تم الاقتراح كإجابة بواسطة Steve Kline 16/جمادى الأولى/1431 02:05 م
    • تم وضع علامة كإجابة بواسطة Bruce-Liu 19/جمادى الأولى/1431 10:59 ص
    16/جمادى الأولى/1431 02:04 م
  • A VB script can run directly from Windows task schedule.  In the task scheduler,  select Add a new scheduled task.  Following the prompts, browse to select your .vbs file.  Name your task and select your schedule to run the task daily and select the time of day to run.  It works just the same as if you want to schedule .Bat file.

    Use the absolute file path in the command. 

    Or call vbs file from a .bat file.

    cscript //nologo c:\test.vbs


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX http://blogs.sivarajan.com/ http://publications.sivarajan.com/ This posting is provided "AS IS" with no warranties, and confers no rights.
    • تم وضع علامة كإجابة بواسطة Bruce-Liu 19/جمادى الأولى/1431 10:59 ص
    16/جمادى الأولى/1431 04:12 م