Windows Task Scheduler does not execute .vbs script as exptected while using CScript.exe

We have a .vbs script that reads a source text file, looks for errors, performs a find/replace and then writes a cleaned version of the file to a destination folder.
When executing the script by manually double clicking on the .vbs file, the script works flawlessly.  But when executing via Windows Task Scheduler using Cscript.exe, it creates an empty, zero byte, text file.  Task Scheduler is set to run
"C:\Windows\System32\cscript.exe" with the Add arguments (optional): C:\Scripts\myscript.vbs.
Does anyone know of a way to make it work using the Windows Task Scheduler?
Part of the Script:
Sub CheckFilesIntegrity()
Dim cleanedfile,strLine,outputStr, tempstr, tmpChar, changeTo, companycode, storestring
Dim ObjFileSys, objFile,objCleanFile
charArray = Array("-","?", "/", "\", ":", "*", """", "<", ">", ",", "&", "#", "~", "%", "{",
"}", "+", "_", ".", "a", "e", "o", "s", "h","i","E", "O","P", "S", "p", "=")
 Set ObjFileSys   = CreateObject("Scripting.FileSystemObject")
 Set objCleanFile = CreateObject("Scripting.FileSystemObject")
 Set objFile = ObjFileSys.OpenTextFile(file.name, ForReading, True)
 textfilename = destinationpath & objfilesys.GetBaseName(file) & ".txt"
 Set cleanedfile = objCleanFile.OpenTextFile(textfilename, ForWriting, True)
 ObjLog.writeline "File containing cleaned up data: " & textfilename
 Do while not objfile.AtEndOfStream
     strLine = objfile.ReadLine()
     tempstr = strLine
     If (Left(UCase(tempStr),8) <> "HPAYMENT") Then
      'fix pay now data entry whre record does not have a company code
      If Mid(tempstr, 18,3) = "000" Then
       companycode = Mid(tempstr,32,3)
       storestring = Left(tempstr,17)
       tempstr =Replace(tempstr,"000",companycode,18,1,1)
       tempstr = storestring & tempstr
       storestring = Left(tempstr,31)
       tempstr= Replace(tempstr,companycode,"000",32,1,1)
       tempstr = storestring & tempstr
      End If
      'remove invalid characters and replace them with zero (filler)
   For Each tmpChar in charArray
    Select Case tmpChar
     Case "-","?", "/", "\", ":", "*", """", "<", ">", ",", "&", "#", "~", "%",
"{", "}", "+", "_", ".", "a", "e", "o", "s", "h","i","E", "O","P", "S", "p", "="
     changeTo = "0"
     outputStr = replace( tempstr, tmpChar, changeTo,1,-1,1 )
    End Select
    tempstr=outputstr
   Next
  Else
   outputStr = tempstr 
  End If
    strLine = outputStr
  cleanedfile.writeline(strLine)
 Loop
 cleanedfile.Close
 Set cleanedfile = Nothing
 Set ObjFileSys = Nothing
 Set objFile = Nothing
 ObjLog.writeline " Completed processing of file: " & textfilename
End Sub

So we ended up getting it to work by replicating the double click function.  Meaning that we created a Batch file that calls the .vbs script, then had Windows Task Scheduler run the Batch file.  In that way all necessary permissions were passed
through from one environment to another, which was failing when we called the .vbs script using CScript.

Similar Messages

  • Running SFTP from script but Task Scheduler does not like part of it.

    Hello,
    I am trying to do some (not so) simple file copying using SFTP in this manner:
     1) Map a drive to the destination, the SFTP program will not accept UNC paths
     2) Use SFTP to copy the files to the target Server
     3) Write a Timestamped entry to a log file
     4) Remove the source files after copy
     5) Remove the drive mapping
    Everything works but Step two and that only fails running from the Task Scheduler (W2K8 R2).  Running from the command line directly in PowerShell or using the Run box works fine all the way.
    The sftp program is BitVise SSH Client using their log utility.  The makes the command line very complicated.
    The line I use in the Scheduler is powershell "D:\Scripts\SFTP_TPCCommission.ps1" Dev  I have also tried using the -command parameter.  Again, it only does not work in the scheduler.
    Here is how I invoke it:
    $CmdLine = "`"D:\\Program Files (x86)\\Bitvise SSH Client\\logs\\`" sftpc " + $Server + " -pk=1 -cmd=`"put -o -lf Z:\" + $File + " /TPCCommissions`""
    & log ($CmdLine)
    I have also tried a Here String to do the same thing.  It works the same way.
    $ArgText = @"
    "D:\\Program Files (x86)\\Bitvise SSH Client\\logs\\" sftpc $Server -pk=1 -cmd="put -o -lf Z:\$File /TPCCommissions"
    Any ideas?

    In a batch file or at the command (not PS) line the command structure looks like this:
    log "D:\\Program Files (x86)\\Bitvise SSH Client\\logs\\" sftpc <user@server> -pk=1 -cmd="put -o -lf Z:\<Source> /<Destination>"
    The double slashes are requirement of the log program which calls the sftpc program with its command structure.
    The double-quoted section after "-cmd=" is required.  The Z: drive is mapped because the SFTP program does not support UNC paths. (Stupid, but that is all I have to work with.
    What you see in my post is just the part giving me trouble.  I am using PS to keep track of what I am copying to the destination and removing from the source and creating a timestamped log of that activity.
    As to the comment about Task Scheduler, I am using it.  Like I said, it all works fine from anywhere but the Task Scheduler.

  • Crontab job does not execute Export script

    Hello Dear Oracle/Linux Gurus,
    I have limited knowledge about Cron job scheduling. After reading few articles/documentation, i have scheduled an Export job with crontab.
    When i run manually script (./exportuser.sh) Then its working fine. But with crontab is doesn't trigger. Log file exist but does not contain any entry, its empty.
    I would be grateful if you could let me know where is mistake?
    Thankyou in advance.
    ----Crontab entries are below here----
    oracle@backup-oracle:~/oracle/product/10.2.0/db_1/admin/orcl/dpdump> crontab -l
    # DO NOT EDIT THIS FILE - edit the master and reinstall.
    # (/tmp/crontab.XXXXFcYToV installed on Mon Dec 5 10:26:28 2011)
    # (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
    * 21 * * * /home/oracle/oracle/product/10.2.0/db_1/rdbms/scripts/exportuser.sh > /home/oracle/oracle/product/10.2.0/db_1/rdbms/scripts/log/exportuser.log
    ----exportuser.sh is below here-----
    cd /home/oracle/oracle/product/10.2.0/db_1/admin/orcl/dpdump
    find /home/oracle/oracle/product/10.2.0/db_1/admin/orcl/dpdump -ctime +7 -exec rm{} \;
    export DATE=$(date +"%d-%m-%Y")
    exp scott/tiger file=scott_md_bk_$DATE.dmp log=scott_md_bk_$DATE.log rows=yes
    gzip scot_md_bk_*

    I suggest to put the following line at the beginning of your exportuser.sh script:
    date >> /tmp/exportuser.started
    Then check the output of /tmp/exportuser.started to see if the script gets actually called. Errors are normally dispatched by email to the user running the cron task. Did you receive any? You can also check the cron log file for errors and should verify that the cron daemon is actually running, e.g. "ps -ef | grep crond". Crontasks can run as root or any user who is allowed to run cron. I'm not so much familiar with Suse, which is quite different to other Linux distros.

  • Using Windows 7, Firefox does not allow a script to work for an online counter that worked fine on Xp. It works fine in IE with Windows 7.

    On several websites, there is an online counter that shows the count, but now that I have Windows 7 it doesn't show the count. IE shows it but not Firefox. It worked fine in XP.

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    See also http://kb.mozillazine.org/Images_or_animations_do_not_load

  • RUNNING PHP SCRIPT WITH ZEND FRMWRK IN WINDOWS TASK SCHEDULER

    I have a PHP script which includes the Zend framework Mail.php for sending mails.
    I am running a WAMP server and i used DW to create it.
    I want to run my script in every 5 mins, How i can schedule it in Windows task scheduler.
    I tried running a bat which contains the php.exe path and arguments as php file but it gives an error that zend/mail.php not found.
    Please help its really urgent.

    Thanks for your response.
    bat file has:
    path of the php.exe -f path of php file.
    But when it runs it gives an error that the zend framework file not found.
    I have a seperate PHP includes folder under which zend FW is stored.
    That folder is marked in includes_paths in php.ini.

  • Upgraded ROX filer not executing shell scripts

    Hi all,
    I run ICEWM+ROX filer as my lite desktop but after a recent upgrade, ROX does not execute shell scripts on mouse click. It appears that filetype detection has changed so that all scripts are shown with the shellscript icon, whereas before those without a .sh extension where shown with the kde type "cogwheel".
    Any tips much appreciated.
    My thanks in advance!

    I've found a lot of things I don't like about the latest ROX upgrade... too much caching nowadays in my  opinion.

  • Windows Task Scheduler executing old triggers even after recreating the task

    I had this task working perfectly until I changed the schedule. After I changed the scheduled time 5 minutes earlier, I noticed that in the history, it still triggers the old schedule. I tried restarting the server, deleting the task and recreating it even
    without a trigger and it's still executing the task with the old trigger. The attached screenshot shows that the task doesn't have a trigger but as you can see in the history it's still trying to execute the task. How does the Windows Task Scheduler work?
    Is there a file or database that I can purge the old task?
    I also tried applying this hotfix but it didn't seem to fix the issue: 
    http://support.microsoft.com/kb/2461249
    NOTE: This is Windows 2008 R2 and the Error message in the history is: Task Scheduler failed to start "<the
    name of my task>" task for user "<the
    user>". Additional Data: Error Value: 2147750689.

    Since batch job can be run manually without error, cmd.exe is not the problem.
    I researched and found that the problem may be due to exhausted desktop heap and the solution is to increase the value.
    Please try this step:
    1. restart the server first and test again (a simple solution that may work)
    2. if the first attempt fail, take a full backup first and attempt to increase desktop heap
         http://www.symantec.com/business/support/index?page=content&id=TECH48099
    Yes THAT WAS THE SOLUTION FOR THE ISSUE. !!
    Now its working perfect!!
    Why now its working and not before? Because after made the changes to the registry,
    RESTART IS NECESSARY to apply the changes and I have done it yesterday night (this server is working 24x7, so its hard to find a moment to restart it). 
    Thanks for all to help me with this issue!!! I really,really ,really ,really  apreciate !!! 
    THANKS !!!!!

  • VBS objshell.AppActivate doesn't work with Windows Task Scheduler

    Hi all,
    This script do the following : 
    Open Adobe Flash media Live Encoder with an encoding profile
    Activate the Adobe Flash... Window
    Send enter key to start encoding
    Set objShell = WScript.CreateObject( "WScript.Shell" )
    objShell.Run """C:\Program Files (x86)\Adobe\Flash Media Live Encoder 3.2\FlashMediaLiveEncoder.exe"" /p ""C:\Users\process\AppData\Roaming\Adobe\Flash Media Live Encoder 3.2\profile.xml"""
    'Loading time
    WScript.Sleep 5000
    objshell.AppActivate ("Adobe Flash Media Live Encoder 3.2")
    WScript.Sleep 5000
    objShell.SendKeys "{ENTER}" 'start encoding
    This script perfectly works manually, but the objshell.appactivate command doesn't work when i run it with the windows task Scheduler.
    Any ideas ? Thx

    Hi to all! I have found workaround for this issue - I wrote vbs, made run it via bat file, and converted the bat file to exe
    vbs
    Set oShell = CreateObject("WScript.Shell")
    If oShell.AppActivate ("Connecting error to Bee") Then
    WScript.Sleep 2000
    oShell.SendKeys "%{F4}"
    End If
    bat
    start C:\Users\User\Desktop\close.vbs
    bat to exe
    Advanced BAT to EXE Converter v2.83
    I know it's some weird solution but it is working with Win Task Scheduler correctly. Try it ;)
    In some cases you need to mark checkbox "run this program as an administrator" and (or not) disable UAC.

  • R1: tcAPIException: Duplicate schedule item for a task that does not allow multiples.

    Hi,
    I'm struggling with the following task:
    I have to assure an account exists for a given resource. I do provision it with the .tcUserOperationsIntf.provisionObject().
    I've created a createUser task to create the account.
    The task code checks if there is already matching account.
    If no account exists, is is created in the disabled state, and the object state of OIM account is set to 'Disabled' by means of task return code mapping.
    If it exists, it is 'linked' to OIM account.
    The problem is if the existing account is enabled, I have to change the OIM account state to 'Enabled' either.
    To implement this (thanks, Kevin Pinski https://forums.oracle.com/thread/2564011 )) I've created an additional task 'Switch Enable' which is triggered by a special task return code. This task always succeeds, and its only side effect is switching the object status to 'Enabled'.
    By I've getting the 'Duplicate schedule item for a task that does not allow multiples' exception constantly:
    This is the stack trace:
    Thor.API.Exceptions.tcAPIException: Duplicate schedule item for a task that does not allow multiples.\
      at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.provisionObject(tcUserOperationsBean.java:2925)\
      at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.provisionObject(tcUserOperationsBean.java:2666)\
      at Thor.API.Operations.tcUserOperationsIntfEJB.provisionObjectx(Unknown Source)\
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\
      at java.lang.reflect.Method.invoke(Method.java:601)\
      at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)\
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)\
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)\
      ...skipped
      at Thor.API.Operations.tcUserOperationsIntfDelegate.provisionObject(Unknown Source)\
      ... skipped
    What did I wrong?
    Regards,
    Vladimir

    Hi Vladimir,
    Please select 'Allow Multiple Instance' checkbox for the process task.
    Thanks,
    Pallavi

  • ITunes downloaded, but does not open-Windows does not support Mac script

    I have recently bought a Toshiba laptop with pre-installed Windows Vista. I have managed to download iTunes, but I cannot open it. The computer posts a message saying that it does not support Mac script. I suppose that I need additional software (daemon tools?)? I would be grateful if someone could advise me in relation to this issue.
    Toshiba Satellite   Windows Vista  

    No, you should need nothing additional. I suspect you may have tried to download the Mac compatible version of iTunes & that's why your getting this message. Make sure you have checked the Windows version & nothe Mac version on the download page.

  • Windows Task Scheduler

    We have script with batch file and its not running on windows 2008 servers..
    the share directory contains sharepoint sites as share drive..
    I have checked the options
    1.Run with highest privilleges
    2. Do not store password
    Can someone help me to get this resolved?

    if you run the batch file via command prompt, does it work as expected?
    or any errors on the task scheduler window?
    have you set the option to run only when user is logged on?
    if it set like that and the user logs off, the task scheduled will not run.
    check out link below for some ideas:
    Set Task Scheduler
    Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
    IT Stuff Quick Bytes

  • Issues with Windows TasK Scheduler

    Hi!
    I'm having two issues recently with Windows Task Scheduler, and I'm wondering if anyone else has experienced this and know of a resolution. We are on Windows Vista.
    Error value 2147750687 - The task we are using has been running successfully since day one, all of a sudden, two concurrent jobs got triggered the other day, thus one of them failed and gave us this error. Why would the scheduler kick off two jobs start at the same time? How can that happen? The settings are "run with the highest privileges" and run whether user is logged on or not".
    Error value 2147549186 - On this one, the task was running as scheduled, no errors in the log, then all of the sudden, after 10 minutes into the job, it re-started “due to a failure”. The settings are set to restart after 5 minutes, 3 attempts, but since it was running, and our logs do not identify any issues, what could have caused the scheduler to think there was an error?
    Joe

    Hi LordTim,
    >>However, I cannot get Access to load<<
    How did you load the Access? Did you use Access object to automate the Access applicaiton?
    If I understood correctly, did Access load successfully when you in a normal script?
    If yes, I think the issue may relative to the Task Scheduler. I suggest that you get more effective response from
    Windows Community forum about Task Scheduler issue.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Windows 2008 R2 does not work on Sunfire X4170

    Hi, I recently bought a used X4170 server and have a weird problem. Windows 2008 R2 does not work, but 2012 does. I tried RTM version and a version with SP1. The problem is this:
    After installing, I set the password and windows just displays a blank desktop, sometimes it boots but freezes soon after - the mouse cursor moved but nothing else works.
    Booting in Safe Mode works and Windows do not freeze. The Event Log contains lots and lots (about 20 per second) of these entries:
    Log Name: 
    System
    Source:   
    Microsoft-Windows-WHEA-Logger
    Date:     
    6/21/2014 12:24:59 AM
    Event ID: 
    17
    Task Category: None
    Level:    
    Warning
    Keywords:
    User:     
    LOCAL SERVICE
    Computer: 
    WIN-SOGS2TPM334
    Description:
    A corrected hardware error has occurred.
    Component: PCI Express Root Port
    Error Source: Advanced Error Reporting (PCI Express)
    Bus:Device:Function: 0x0:0x0:0x0
    Vendor ID:Device ID: 0x8086:0x3406
    Class Code: 0x30000
    I have tried updating the driver for this device (downloaded from Intel), no difference. Is there a way to make Windows 2008 R2 work on this server?

    Hello
    Thank you for the update.
    Please refer the below Knowledge document related to this issue:
      Windows BSOD WHEA_UNCORRECTABLE_ERROR(124) & correctable WHEA events when disabling network ports on X4170M2/X4270M2 (Doc ID 1576683.1)
    However above document talks about X4170M2, I would suggest you to follow and if issue persist, please open Service Request with Oracle to diagnose further.
    Best Regards
    Bhavyesh

  • PSE 6: Task bar does not pop up in Editor

    When I move the cursor to the bottom of the screen in the PSE 6 Editor, the task bar does not open. I have to hit the Windows key to do it.
    Work o.k. in the Organizer.
    Windows Vista.
    Any ideas? - Thanks!
    Alexander

    Thats a bug that seems to be fixed in PSE 7. But theres a workaround instead of maximizing the Editor, manually resize it to fill the screen except for a strip of a couple of pixels along the bottom. The Editor will remember its last position when you next open it.

  • Global succession updates are limited to 500 relationships. If more than 500 exist PLM presents a warning message and does not execute the update

    Global succession updates are limited to 500 relationships. If more than 500 exist PLM presents a warning message and does not execute the update.
    How/Where to increase the relationship count?
    The message which I can see :
    Warning:
    This specification has exceeded the number of parent relationships allowed by Where Used. The Where Used tool only supports up to 500 parent relationships.
    Thanks

    This really brings up a larger topic around change management.
    The questions you should start with is
    1. What kind of change is happening to the raw material? 
    2. Will this change affect anything upstream inside or outside of PLM4P? (Will this change affect nutrition, compliance, the ingredient statement, the label etc?)
    3. Who needs to approve this change?
    If they are non-material changes (changes that don't affect theoretical calculations, the ingredient statement, labeling, upstream systems that need to be notified etc) then you should be using get latest revision instead of global succession.   Get Latest Revision will automatically switch out the material with the latest approved version.  This logic is also configurable in case you need to add additional guard conditions.   We can also provide guidance around locking the get latest revision lock once a specification has reached the retired/obsolete state so changes won't occur for specifications in those statuses.
    If the changes to the raw material are material changes (changes that affect calculations, labeling etc) then the change should be reflected with a copy of the specification.  Dependent specifications then need to be re-issued so calculations can be performed and the appropriate workflow reviews can occur.   Smart Issue allows for filtering based on status and should let you re-issue in smaller blocks. 
    Let me know more about your change management strategy, how often large material changes happen and maybe example causes for those mass changes.  We can also schedule a change management training session for everyone where we can share our vision and tools available for change management.  This topic is quite large and generally requires a lot of business process discussion beyond just the tools available. 
    Thanks
    Kelly

Maybe you are looking for

  • Ipod classic fault

    My ipod classic has wiped clean and no longer shows in itunes windows message just says need to format disk f but cant format it please help

  • Os x not installing

    Hello community, OS X has been trying to install for months now on my iMac and has not succeeded. It downloads as if it never has before, then starts the install and shortly after, the install fails. Why? What needs to be done? Thank you for any advi

  • F110 - Code 051 error

    Good morning Forum, the problem that considers is the following one. When I carry out the F110, treating the proposal and brings all the open items. Many of them with error 051. error in calculate of retentions. If I individually select same open ite

  • Procdure fails 2nd time executed

    I have a procedure (below) that is executed by a WHEN-BUTTON-PRESSED trigger. The first time in a session that I push the button, executing the procedure, it's successful, the second time, my form just goes blank and locks up. I've narrowed it down t

  • How can create color table for "write bmp file.vi"?

    i want to create a color table for a 8 bit bitmap.The color table is the input of "write bmp file.vi". how can i make it? thanks!