none
Variable Performance with VBScript - Faults (on some systems) with 800A01AD RunTime Error RRS feed

  • Question

  • Hi Scripting Guys,

    I am seeking some advice in respect of a RunTime error which triggers on some systems but runs flawlessly on others, all are running Windows 10 Pro (64 Bit) and Office 2016 (64 Bit). This is perplexing me as I do not understand what is interacting to trigger the issue.

    To give some background the script is to automate the start of Outlook 2016 (64 Bit) during boot or user login whilst also pausing (briefly) to allow initiation of mail collection before minimising invisibly (NB. "Hide when minimised" assigned to Outlook tray icon from it's context menu) into the system tray where it will obviously continue to work in the background until required by the user ("Open Outlook" from tray icon's context menu) at which point the Outlook window will again maximise to facilitate use.

    The .vbs Script is in turn assigned a shortcut which is set as a registry string in HKCU>run triggering on boot. The script has also been tested with the shortcut placed in the user's startup folder instead as an alternate means of trigger with the same result.

    The RunTime Error:

    Script: D:\Neil's Files\Neil's Filing Cabinet\Neil's Emails\Start Outlook Minimised to Tray\Start Outlook 2016 Minimised To Tray.vbs

    Line:   11

    Char:   5

    Error:  ActiveX component can't create object: 'GetObject'

    Code:   800A01AD

    Source: Microsoft VBScript runtime error

    As noted previously on the systems where the RunTime error does not trigger the operation is flawless with all automated actions carried out as intended. On the faulting systems, Outlook does trigger with the maximised window, commence mail collection but then fails to automatically minimise to the tray as intended.

    The system differences, for comparative purposes I will summarise those I feel to be relevant here:

    System 1: (1st problem system) is an X58 Asus P6T7, Intel i720 mature PC with many programs installed and specifically the Outlook 2016 has the same 12 addins installed but in addition has two related programs which launch at boot, the enterprise editions of 4team's Sync2 for Microsoft Outlook and Safe PST Backup. The boot times are quite lengthy (but acceptable) as is the Outlook Startup with it's various addins.

    System 2: (2nd problem system) is HP Elitebook 8440P Laptop - Windows 10 Pro 64 Bit with Office 64 Bit + same 12 Outlook Addons - Above RunTime error experienced as with System 1.

    System 3: Is a current generation Asus X99-Deluxe, i7 5930 new build pc with little installed as yet save MS Office, Adobe CC and some utilities.

    System 4: Like System 2, is also a HP Elitebook 8440P Laptop - Windows 10 Pro 64 Bit with Office 64 Bit + same 12 Outlook Addons. It is of a slightly lower performance specification than its System 2 companion.

    In the case of Systems 1 & 2, Outlook auto-starts as intended however during it's loading splash screen (whilst it is loading up the addins) the runtime error is displayed although Outlook continues to open fully but fails to minimise..... Systems 3 & 4 are free of issue.....perplexing!

    Analysis of the error dialogue suggests to me that the faulting code is the section which activates the window however the above error message refers to "ActiveX component can't create object: 'GetObject'" which perhaps suggests instead an issue with the code line "Set OLObj = GetObject("","Outlook.Application")"?? I am quite a code novice so my interpretations are most likely flawed!!

    I would welcome any thoughts/observations....

    The Code:

    OPTION EXPLICIT
     
        Dim WshShell
        Dim OLObj
        Set WshShell = WScript.  CreateObject ( "Wscript.Shell" )
        WshShell.Run "OUTLOOK.EXE" , 3, false
        WScript.Sleep (10000)
        Set OLObj = GetObject("","Outlook.Application")
        OLObj.ActiveExplorer.Activate
        OLObj.ActiveExplorer.WindowState = 1

     

    Tuesday, August 8, 2017 1:01 PM

Answers

  • No.  Nota a PITA but you could certainly gain be learning basic Windows.  You can also answer many of your question be searching.

    Unfortunately teaching you Windows and scripting is beyond the scope of this forum.  Search and you will find many resources that will help you learn.

    Running the script with the cscript program directly forces it to run in the 32 bit subsystem.  On a 64 bit PC the default is 64 bit.  It is not a tst.  It is how you need to run the script until you find the issue with Outlook and fix it.

    We do not "compile" scripts. Scripts are just run as it.

    Again.  You need to learn basic Windows and basic scripting.  Forget VBScript and learn PowerShell.

    To start outlook minimized at logon use a shortcut in the "Startup" folder.  A shortcut can start a program in a specific window state.


    \_(ツ)_/

    Wednesday, August 9, 2017 9:59 PM

All replies

  • Set WshShell = CreateObject ( "Wscript.Shell" ) 
    WshShell.Run "OUTLOOK.EXE" , 3, True
    Set ol = CreateObject("Outlook.Application")
    ol.ActiveExplorer.Activate
    ol.ActiveExplorer.WindowState = 1



    \_(ツ)_/


    • Edited by jrv Tuesday, August 8, 2017 6:51 PM
    Tuesday, August 8, 2017 1:20 PM
  • Hi jrv,

    Thanks for taking the time to respond so promptly!

    I have tried the code suggested on the faulting X58 desktop system and now receive a similar Windows Script Host dialogue as follows:

    Script: D:\Neil's Files\Neil's Filing Cabinet\Neil's Emails\Start Outlook Minimised to Tray\Start Outlook 2016 Minimised To Tray.vbs

    Line:   3 

    Char:   5

    Error:  ActiveX component can't create object: 'Outlook.Application'

    Code:   800A01AD

    Source: Microsoft VBScript runtime error

    Curiously, as with my original code (which I have now retested in the same manner) on initial test of the script without booting the PC but without Outlook running the desired behaviour appeared to be satisfied. However, the error was returned immediately upon boot indicating that something in the boot process is causing "Set ol = CreateObject("Outlook.Application")" (i.e. code Line 3) to fail to initiate??

    I also have a couple of further general 'novice' questions in respect your code:

    1. The original sample I provided was "OPTION EXPLICIT" whereas your code was not.....can you explain (in simple terms...lol) what differences this brings to the operation of the .vbs script?

    2. I may have been under a misapprehension, but understood that on launch Outlook required a pause before the auto minimise to successfully initiate mail collection (assuming 'send mail immediately on connection' and the accounts are configured to be included in the 'all accounts group' of course). This was my reason for including WScript.Sleep (10000).... i.e. a 10 sec pause

    Thanks again, I look forward to hearing your thoughts!


    • Edited by P C Pilot Tuesday, August 8, 2017 8:11 PM
    Tuesday, August 8, 2017 6:29 PM
  • you cannot use GetObject with Outlook.  Outlook only allows one instance and CreateObject just attaches to an existing Outlook process.

    My code is all you need.

    I recommend that you drop VBScript as it is almost obsolete. If you need to learn to script then start with PowerShell.  All new subsystems only support PowerShell and the Net Framework. VBScript cannot access any of these things.

    Almost all of your assumptions are misguided as you have been looking at posts and examples that are likely wrong or poorly implemented.

    Start b y learning basic PowerShell. After that you will need to learn how a product is designed and how its object model work. A good short course in general programming would be very helpful.

    I would point you at VBScript documents on Microsoft but, unfortunately, Microsoft has been removing references to VBScript from all sites so most links I have no longer work.


    \_(ツ)_/

    Tuesday, August 8, 2017 6:43 PM
  • Try running your script with this command line:


    C:\Windows\SysWOW64\cscript.exe "D:\Neil's Files\Neil's Filing Cabinet\Neil's Emails\Start Outlook Minimised to Tray\Start Outlook 2016 Minimised To Tray.vbs"


    -- Bill Stewart [Bill_Stewart]

    Tuesday, August 8, 2017 6:44 PM
    Moderator
  • You should not and do not have to use "sleep" as the "Run" method will wait for the program to start before continuing.

    I can launch the script as a 64 bit script and it accesses the Outlook object correctly.  This has always been Outlook behavior although other COM objects may not behave that way.

    Get-Object is not useful and will fail because of the design of Outlook  CreateObject attaches to the running Outlook process correctly and requires no waiting.


    \_(ツ)_/

    Tuesday, August 8, 2017 6:56 PM
  • I should also note that the code I posted correctly minimizes the Outlook Window.  This will not work as expected if Outlook is already running.  You will get a duplicate Window but it will still be the same Outlook process.  If you want 2 identical Windows then OK.  If not check to see if Outlook is already running and skip the "Run".


    \_(ツ)_/

    Tuesday, August 8, 2017 7:01 PM
  • Hi jrv,

    Just realised a copy and paste blunder has been made with my runtime error dialogue (now corrected above)....should have read: ActiveX component can't create object: 'Outlook.Application'  AND NOT ActiveX component can't create object: 'GetObject'  as I reported......I guess that's what I get copying the earlier text and not revising it correctly!..........carried forward errors must be a coder's nightmare?  lol.

    Apologies also for my novice ignorance here, I DID use just your code though (through sheer ignorance) saved as a VBScript file. Obviously I have been tackling this from completely the wrong approach as you rightly surmised, following examples reported by others which are I guess wrong or poorly implemented...never a wise starting point I'm sure.

    I do appreciate your point that PowerShell indeed offers better solution from what you describe, but as with that well known joke about a tourist in Ireland who asks one of the locals for directions to Dublin to which the Irishman replies: ‘Well sir, if I were you, I wouldn’t start from here’!! ....... in what alternate format than as a .vbs would you suggest that I compile your code, as of now?  .....and how best do I start from here?

    I freely hold my hands up and admit to my limitations as a novice here. However, all of my IT knowledge has been developed through practical experience and whereas I would not have contemplated (even very poorly as you have seen  lol) adapting code to solve a problem just a few years ago my determination to learn and achieve results has so far seen me resolve (perhaps with help) most issues, including using of code even though my understanding was most basic. These solutions were likely inelegant and most probably poorly compiled but they DID solve the problems and in doing so developed my understanding :)

    As you suggest, I will try and start learning basic PowerShell, as well as brushing up on my general programming but right now the best I have is your kindly offered replacement code incorrectly compiled as a VBScript file which clearly is not fit for purpose. How might this be put in a PowerShell format instead? 

    I am truly appreciative of your time in assisting me and trust that my honest appraisal of my shortcomings does not put you off from answering my dumb questions!

    Tuesday, August 8, 2017 9:56 PM
  • Thanks for your response Bill.....very much appreciated!

    As advised I have tested my script using the suggested command line in PowerShell (with Outlook closed of course!) and can report that it behaves flawlessly....

    Maybe the issues are related to the boot sequence/process?

    Is this the result you expected?

    Tuesday, August 8, 2017 10:07 PM
  • Assuming Outlook is running:

    $ol = New-Object -ComObject Outlook.Application
    $ol.ActiveExplorer().WindowState = 1
    


    \_(ツ)_/

    Tuesday, August 8, 2017 10:17 PM
  • Thanks for your response Bill.....very much appreciated!

    As advised I have tested my script using the suggested command line in PowerShell (with Outlook closed of course!) and can report that it behaves flawlessly....

    Maybe the issues are related to the boot sequence/process?

    Is this the result you expected?

    That indicates that you have an issue with the Outlook install or you are using a very old version of Outlook.


    \_(ツ)_/

    Tuesday, August 8, 2017 10:19 PM
  • Ahh.....I see, that is indeed a much more refined approach and quite seamless (at least with the two systems on which it is working flawlessly).

    I guess the script launch is what Bill Stewart was suggesting?  If so my test results above confirm your observations..

    Thank you for clarifying the limitation of Get-Object in respect of Outlook. CreateObject as in your code compilation is clearly the answer so I am grateful for that!

    Tuesday, August 8, 2017 10:20 PM
  • There is no compilation.  Bill merely suggested you try and run the vbscript as a 32 bit application.


    \_(ツ)_/

    Tuesday, August 8, 2017 10:21 PM
  • Thanks again jrv.....The code is only intended (other than for testing) for auto start at boot/user logon so Outlook would never intentionally be running. All of my tests with the PC already booted have been with Outlook closed with the intention of mimicking (to some extent) the actions anticipated in the boot environment. 
    Tuesday, August 8, 2017 10:36 PM
  • Thanks jrv......think our posts on the same subject crossed see my reply above!
    Tuesday, August 8, 2017 10:39 PM
  • In respect of the installed version of Outlook 2016 (64 Bit) - V16.0.4549.1000 - Fully Updated to last installed update at 1st August 2017......

    Not sure on what the install issue might be?  Sequence in the boot process?? Interaction of another programme which works in conjunction with Outlook, iCloud, 4Team apps etc. ?? Any other thoughts?

    • Proposed as answer by jrv Wednesday, August 9, 2017 9:52 PM
    • Unproposed as answer by Bill_StewartModerator Friday, August 11, 2017 3:03 PM
    Tuesday, August 8, 2017 10:49 PM
  • Please excuse the ignorance but why test the vbscript as a 32 bit application?
    Tuesday, August 8, 2017 10:53 PM
  • Please excuse the ignorance but why test the vbscript as a 32 bit application?

    Because something is wrong with your Outlook installation and it doesn't launch correctly from a 64bit prompt.

    I m running Outlook 2016 V16 on all systems and never have seen your issue.

    Note that you can cause Outlook to minimize by starting it from a shortcut placed in the startup folder.  A script is never needed for this.


    \_(ツ)_/

    Tuesday, August 8, 2017 11:19 PM
  • OK, and sorry if you all regard me to be a PITA over this......but I am keen to learn and develop a better understanding not just to freeload by requesting code samples...

    If I understand jrv correctly, the C:\Windows\SysWOW64\cscript.exe command line test was intended to isolate the issue and prove that it resides with the Outlook 64 bit installation by testing the script at a 32 bit command prompt instead?

    Accordingly, the corresponding test under the 64 bit command prompt would be C:\Windows\System32\cscript.exe "D:\Neil's Files\Neil's Filing Cabinet\Neil's Emails\Start Outlook Minimised to Tray\Start Outlook 2016 Minimised To Tray.vbs"  .....which is interesting as using that command line the script behaves without issue for 95% of the time.

    Occasionally, however the 64 Bit PowerShell prompt reports the following VBScript runtime error: Object required: 'ol.ActiveExplorer'. No doubt this is the same fault which triggers on each boot?

    I understand your observation that "something is wrong with your Outlook installation" and with that in mind I have performed an 'Office Repair' but this has not had any effect on the vbscript error at boot.

    Given the reference (Object required: 'ol.ActiveExplorer') reported can anybody suggest what is likely to cause such fault and how I might look to address the problem?

    On the subject of the more optimal alternate PowerShell script suggested as a better means of performing the desired actions in the first place and discussed yesterday. I wonder if this would overcome the problem as it functions in a different manner than VBScript? If so, can anyone suggest a practical way in which I might translate the code and compile a suitable alternate PowerShell script along the lines jrv recommended?

    Everybody's input is very much appreciated, and I can only apologise for my limited understanding which I find frustrating, as no doubt everyone here does too!  lol

    Wednesday, August 9, 2017 9:36 PM
  • No.  Nota a PITA but you could certainly gain be learning basic Windows.  You can also answer many of your question be searching.

    Unfortunately teaching you Windows and scripting is beyond the scope of this forum.  Search and you will find many resources that will help you learn.

    Running the script with the cscript program directly forces it to run in the 32 bit subsystem.  On a 64 bit PC the default is 64 bit.  It is not a tst.  It is how you need to run the script until you find the issue with Outlook and fix it.

    We do not "compile" scripts. Scripts are just run as it.

    Again.  You need to learn basic Windows and basic scripting.  Forget VBScript and learn PowerShell.

    To start outlook minimized at logon use a shortcut in the "Startup" folder.  A shortcut can start a program in a specific window state.


    \_(ツ)_/

    Wednesday, August 9, 2017 9:59 PM
  • I agree with jrv. If the purpose of the script is to start Outlook minimized, then you don't need a script. Just create a shortcut that starts Outlook minimized. If you want it to run when you log on, then put it in the "startup" folder.

    -- Bill Stewart [Bill_Stewart]

    Thursday, August 10, 2017 2:21 AM
    Moderator