ActiveX component can't create object: 'WScript.Shell'

Posted on 2006-05-05
Last Modified: 2013-12-03
This is the file that the problem occurs in.. prefastnew.dsm:
Sub PrefastNew()
'DESCRIPTION: Reads the compilation options from the active project and compiles the active file with Prefast using these options
 Dim PathString
 If Application.Documents.Count > 0 then
  PathString = ActiveDocument.FullName
  Exit Sub
 End if
 Dim objShell
 Set objShell = CreateObject("WScript.Shell")
 Dim Args
 If Projects Is Nothing Or Projects.Count < 1 Then
  ' Ask the user for preprocessor symbols e.g. _ADMIN. _DATASERVER, etc.
  ' Then prefast the actiuve file
  Args = "C:\Prefast\prefastnew.bat " & PathString
  ' Get the compile options from the current dsp
  ' Then prefast the active file
  Args = "cmd /V:on /c ""C:\Prefast\prefastnewVs6.bat " & ActiveProject.FullName & " " & ActiveDocument.FullName & """"
 End If
 objShell.Run Args
End Sub
This is the error:
Line 11: ActiveX component can't create object: 'WScript.Shell'
This is what I've tried:
My OS is Windows XP Version 5.1(build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)
I made all internet explorer security settings low to allow execution of all ActiveX components.
I checked that "C:\WINNT\System32\wshom.ocx" is present on the system
I tried running wscript -regserver
I tried adding the registry entry "Remote" with a value of 1 to "HKEY_LOCAL_ MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings" registry subkey
I ran regsvr32  /v C:\WINDOWS\system32\wshom.ocx and checked that this is registered correctly. It apppears fine in the registry.
I ran all windows updates and reinstalled Windows XP service pack 2.
Lots of help on the net suggest that the problem may be with the syntax of Set objShell = CreateObject("WScript.Shell").   This line is correct for it's current use and the problem seems to be only with the object "WScript.Shell"
Question by:pjbroe
    LVL 8

    Accepted Solution

    1. Do you have such registry key ?


    @="Windows Script Host Shell Object"

    [HKEY_CLASSES_ROOT\CLSID\{72C24DD5-D70A-438B-8A42-98424B88AFB8}\Implemented Categories]

    [HKEY_CLASSES_ROOT\CLSID\{72C24DD5-D70A-438B-8A42-98424B88AFB8}\Implemented Categories\{40FC6ED5-2438-11CF-A3DB-080036F12502}]






    2. Does following "test.vbs" (create such file and fill with contents below) file executes successfully ?

    Dim obj

    Set obj = CreateObject("WScript.Shell")

    LVL 8

    Expert Comment

    I have checked ".dsm" file (macro for Visual Studio project)
    with following lines:

    Dim obj
    Set obj = CreateObject("WScript.Shell")

    and it still works

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
    As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now