Restoring .vbs (VBScript Script File) File Associations

“I am running Windows XP. I need to execute VBS scripts to run functions in other programs. I had no problem until some security program disabled execution of VBS Scripts. Now all I get is code Notepad and the VBS Scripts don’t execute. How do I get Windows to execute VBS Scripts again?” – Peter A.

Peter, if double clicking your VBS files results in them opening in Notepad, your security application has disabled VBS execution by changing the default application used to open the VBS file. In Windows, this is managed by File Associations. Let’s take a look at how to restore the default VBS File Associations.

You can restore the default application used to Open a file by changing it’s file association. If you open My Computer and choose Folder Options… from the Tools menu, you can find file association on the File Types tab.

Since the VBS file will open in Notepad, the file type is still registered on your system. Scroll through the list of file types until you find the VBS (VBScript Script File) entry. Select it and press the Advanced button.

The Edit File Type dialog box will appear. Here you can edit any of the various file associations for a given file type. In this case, we want to change the application used to Open a file. Select Open in the action list and press the Edit… button.

In the Application used to perform action: field, enter the following command line:

C:\WINDOWS\System32\WScript.exe “%1” %*

Tick the checkbox marked Use DDE and enter the word WScript in the Application field and System in the Topic field. Now click Ok to close all open dialogs.

If you want to restore all of the default actions for the VBS file type, you can import the following .REG file.

FixVBSFileAssociationsXP.reg Windows XP only!

Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\.vbs]
@="VBSFile"
 
[HKEY_CLASSES_ROOT\.vbs\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
 
 
[HKEY_CLASSES_ROOT\VBSFile]
@="VBScript Script File"
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
  00,6f,00,6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
  32,00,5c,00,77,00,73,00,68,00,65,00,78,00,74,00,2e,00,64,00,6c,00,6c,00,2c,\
  00,2d,00,34,00,38,00,30,00,32,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,53,00,\
  63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,2c,00,32,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\ScriptEngine]
@="VBScript"
 
[HKEY_CLASSES_ROOT\VBSFile\ScriptHostEncode]
@="{85131631-480C-11D2-B1F9-00C04F86C324}"
 
[HKEY_CLASSES_ROOT\VBSFile\Shell]
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Edit]
@="&Edit"
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Edit\Command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,6f,00,\
  74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,20,00,25,00,31,00,00,\
  00
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open]
@="&Open"
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,53,00,\
  63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,31,\
  00,22,00,20,00,25,00,2a,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open2]
@="Open &with Command Prompt"
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open2\Command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,43,00,53,00,\
  63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,31,\
  00,22,00,20,00,25,00,2a,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Print]
@="&Print"
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Print\Command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,6f,00,\
  74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,70,00,20,\
  00,25,00,31,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx]
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx\PropertySheetHandlers]
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx\PropertySheetHandlers\WSHProps]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

On Windows Vista systems, you should use the following .reg file instead.

FixVBSFileAssociationsVista.reg Windows Vista and Windows 7 only!

Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\.VBS]
@="VBSFile"
 
[HKEY_CLASSES_ROOT\.VBS\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
 
[HKEY_CLASSES_ROOT\VBScript]
@="VB Script Language"
 
[HKEY_CLASSES_ROOT\VBScript\CLSID]
@="{B54F3741-5B07-11cf-A4B0-00AA004A55E8}"
 
[HKEY_CLASSES_ROOT\VBScript\OLEScript]
 
[HKEY_CLASSES_ROOT\VBSFile]
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
  00,6f,00,6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
  32,00,5c,00,77,00,73,00,68,00,65,00,78,00,74,00,2e,00,64,00,6c,00,6c,00,2c,\
  00,2d,00,34,00,38,00,30,00,32,00,00,00
@="VBScript Script File"
 
[HKEY_CLASSES_ROOT\VBSFile\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,53,00,\
  63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,2c,00,32,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\ScriptEngine]
@="VBScript"
 
[HKEY_CLASSES_ROOT\VBSFile\ScriptHostEncode]
@="{85131631-480C-11D2-B1F9-00C04F86C324}"
 
[HKEY_CLASSES_ROOT\VBSFile\Shell]
@="Open"
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Edit]
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Edit\Command]
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
  00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,\
  6f,00,74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,22,00,20,00,25,\
  00,31,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open]
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command]
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
  00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,\
  53,00,63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,22,00,20,00,22,\
  00,25,00,31,00,22,00,20,00,25,00,2a,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open2]
@=hex(2):4f,00,70,00,65,00,6e,00,20,00,26,00,77,00,69,00,74,00,68,00,20,00,43,\
  00,6f,00,6d,00,6d,00,61,00,6e,00,64,00,20,00,50,00,72,00,6f,00,6d,00,70,00,\
  74,00,00,00
"MUIVerb"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,\
  6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,\
  00,77,00,73,00,68,00,65,00,78,00,74,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,\
  34,00,35,00,31,00,31,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Open2\Command]
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
  00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,43,00,\
  53,00,63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,22,00,20,00,22,\
  00,25,00,31,00,22,00,20,00,25,00,2a,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Print]
 
[HKEY_CLASSES_ROOT\VBSFile\Shell\Print\Command]
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
  00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,\
  6f,00,74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,22,00,20,00,2f,\
  00,70,00,20,00,25,00,31,00,00,00
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx]
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx\PropertySheetHandlers]
 
[HKEY_CLASSES_ROOT\VBSFile\ShellEx\PropertySheetHandlers\WSHProps]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

You may also download the .reg files here.

FixVBSFileAssociationsXP.reg

FixVBSFileAssociationsVista.reg

Tags

Like the read? Share it!

27 Comments

  • Followed instructions. Tried to run a VBS Script and got the following error message:

    Windows Script Host

    There is no script engine for file extension “.vbs””

    The clicked to download the fix for XP that you provided but when I ran it, I just got a few lines of code in Notepad and the reg file didn’t run.

    Help

  • Hello Peter.

    It sounds as though your .reg file type has been changed as well. This is somewhat common since some administrators will disable the ability to import registry changes.

    You can try importing the registry file from the command line and see if that works. Open a Command Prompt window and navigate to the folder where you saved the .reg file that you downloaded. It can be imported using REGEDIT from the command line.

    regedit FixVBSFileAssociationsXP.reg

    You can repair your .reg file associations with one of the files below. You’ll likely need to import it as I’ve shown you above.

    FixREGFileAssociationsXP.reg
    FixREGFileAssociationsVista.reg

    As for your error message, see my post “There is no script engine for file extension” error when opening .vbs files.

  • Worked like a charms! Thank you very much!

  • Thank you. It was really helpful

  • You saved me a lot of headache…

    Keep up the good work.

  • THANK YOU!

  • Thanks so much! This finally fixed my 4-month broken cscript .vbs issue on Windows 7!

  • Thanks!
    I got the ‘There is no script engine for file extension “.VBS”‘ error, and spent about 30 minutes searching online for a solution. No one else seemed to have the right solution for anyone (that I found), going back 10 years of advice!

    Your registry entries solved it for me on Windows 7. MSDN describes the issue (“This file extension is not mapped to a script engine.”) and how to solve it: “Check your file extension and also the spelling of your scripting language designation.” or “Use //E to designate a script engine.” At last the last item is a workaround, from the command prompt, to get a script to run.

    Pretty sure setting Notepad++ to associate with VBS files caused the problem for me (from the NP++ interface). I should probably let them know…

    Your real solution is much appreciated 🙂

  • Your vista reg key works in Windows 7, thanks.

  • I received this error when trying to run this script on a Windows 7 machine that won’t let me associate .vbs with either cscript or wscript. The default box is greyed out

    Cannot import FixVBSFileAssociationsVista.reg: Not all data was successfully written to the registry. Some keys are open by the system or other processes.

  • [HKEY_CLASSES_ROOT\.vbs]
    @=”VBSFile”

    Already solved it for me.

  • Hey Nilpo,
    You may remember me (omrsafetyo) as the BATCH guru from devhardware
    I happened across this article trying to fix a wsf file association issue for a client – I was trying to determine where “windows script host” was kept – wasn’t sure if it was vbscript.exe or wscript.exe, or something else entirely. I did my google search “how to associate a file type with windows script host” and this was the first page that caught my eye as relevant. Just wanted to say hi, and thanks for the assist!

  • @Nathan,

    Of course I remember you. Thanks for stopping by. I’m glad you found it useful.

    Nilpo

  • @Asa,

    Hey, you may found my problem as well! My .vbs association keeps getting “lost” even after I fix it, and I use (and love) Notepad++ as well, and used the interface setup options to set .vbs to be edited w/ Notepad++ instead of the default of Notepad. I won’t know for sure for a few days, but thanks for the heads-up!

    Thanks for the help Nilpo, the good posters here, and the folks over @ http://kiranpatils.wordpress.com/2009/08/13/there-is-no-script-engine-for-file-extension-vbs/ ! (look there for an easy way to reset the defaults using the %windir%\inf\wsh.inf file! – thanks to kiranpatils)

  • Hello,

    I am trying to open a mapped script on windows 7 but i am not able to , which i was able to open in xp… Is there anything i need to change in the script to make it work for Win 7

  • Hi all,
    I wrote code in *.vbs file, I used Notepad++ to edit this file, but when my computer suspended, I restarted my computer, and my file was broken, so when I opened this file, it only display “null nul nul … ”
    size of this file is 150kb, no change with before it had this problem.

    Can you help me solve this problem?
    Thank you very much.

    Best regards,
    Hieu Tran

  • I have encountered the same problem and went with the regit suggestions for Windows 7, I received this message
    “can not import FixVBS File associations. Vista.reg: error opening the file. There may be a disk or File system error.

    Thanks in advance for any suggestions
    Tommy

  • Hello friends,
    Can any one suggest any solution

    I have to automate IE – 8 in Windows 7.I want to send somekeystrokes on a IE-8 web page just by pressing a hot key.My code is working well in Windows XP – IE-6 but its not working in Windows 7 – IE-8.
    The code :
    Set objShell = WScript.CreateObject(“WScript.Shell”)
    objShell.AppActivate(“Sign in to Yahoo!7 with your Yahoo! ID – Microsoft Internet Explorer”)
    objShell.SendKeys”%{enter}”
    objShell.SendKeys “5”
    objShell.SendKeys “{Tab}”
    objShell.SendKeys “6”
    I am running this code in .VBE extention file
    (To run this code please open up http://www.yahoomail.com web page first)

    Thanks and reagards
    Robbs

  • @Robbs: I’ve already responded to your thread in the forums. Please don’t spam irrelevant posts.

  • Thanks for your explanations, links and the code!!

    It worked for me on Windows Vista.
    I was trying to install postgresql and after looking with google for weeks, finally I found your page. No way to resolve in microsoft forums.

    Best regards,
    Carlinhos

  • Hi there! Do you use Twitter? I’d like to follow you if that would be ok. I’m definitely enjoying your blog and look forward to
    new posts.

  • Thanks. Fix confirmed!

  • Fix is recommended! Regfix for Windows Vista and 7. Thumbs up!

  • Thank you very much! Very helpful and effective fix! 🙂

  • OK, not to sound like a wiseguy, but you’re dabbling in answers.
    The reason the WScript doesn’t run and throws that error is because the associated ID for that extension doesn’t have the engine defined.

    For instance, I don’t want my script to run on the interpreter (i.e. to get “executed”, makes Windows a lot safer) on double click and I also want them to open by default in the editor of my choice, like Notepad++.

    1) So what I do is I associate from within Notepadd++ the extention vbs.
    2) I go in the registry, look in HKEY_CLASSES_ROOT for .vbs, and check what it has as default value.
    3) In this case, it’s Notepad++_file. If a different editor is used, it’s something else.
    4) In the same HKEY_CLASSES_ROOT I look for the KEY named Notepad++_file.
    5) Once found, I create in it a subkey called ScriptEngine and in that I set the (Default) value VBScript.

    That’s it.

    That’s all the VBSFile Key has over any other custom keys that makes it work.

    Basically, WScript, looks for that ScriptEngine key, if it’s not there because the default ID for .vbs files doesn’t set it by default, it throws that error. It’s an out of the ordinary case, since most files don’t need such settings, thus, N++ and others won’t set it properly.

  • Hi, Em.

    Thanks for stopping by. I appreciate your comments.

    You are correct about the ScriptEngine key. The person asking the question wanted to know how to restore the default association so that was the solution I provided.

    Thanks for pointing out that you can definitely customize this option. I personally use the default associations with a custom editor.

  • […] the previous two solutions didn’t work, you should restore the file associations for the .vbs (VBScript) file type by downloading and running one of the registry files […]

Leave a Reply

Contact

Wanna say hello?
Drop us a line!

You'll find us here

1 Microsoft Way,
Redmond,
WA 98052, United States