Restoring .vbs (VBScript Script File) File Associations

July 9th, 2009

“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

Please use the trackback link when linking to this post.

Related Posts:

Add to Technorati Favorites

24 Responses to “Restoring .vbs (VBScript Script File) File Associations”

  1. Peter A Says:

    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

  2. Nilpo Says:

    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.

  3. Structed Says:

    Worked like a charms! Thank you very much!

  4. Ravi Says:

    Thank you. It was really helpful

  5. Tom Souza Says:

    You saved me a lot of headache…

    Keep up the good work.

  6. Scott Says:

    THANK YOU!

  7. James Says:

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

  8. Asa Says:

    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 :)

  9. Lord Nutsack Says:

    Your vista reg key works in Windows 7, thanks.

  10. Kevin Says:

    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.

  11. Bart Says:

    [HKEY_CLASSES_ROOT\.vbs]
    @=”VBSFile”

    Already solved it for me.

  12. Nathan Kulas Says:

    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!

  13. Nilpo Says:

    @Nathan,

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

    Nilpo

  14. Jim Says:

    @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)

  15. Eddie Says:

    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

  16. Hieu Tran Says:

    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

  17. Tommy Says:

    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

  18. Robbs Says:

    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 www.yahoomail.com web page first)

    Thanks and reagards
    Robbs

  19. Nilpo Says:

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

  20. Carlinhos Says:

    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

  21. jump exercises Says:

    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.

  22. vicsar Says:

    Thanks. Fix confirmed!

  23. Tharinda Says:

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

  24. Žanas Stundys Says:

    Thank you very much! Very helpful and effective fix! :)

Leave a Reply

.htaccess Apache article articles by Nilpo ASP ASP Free automation clipboard copy desktop Dev Shed docx Internet Explorer message box Microsoft PHP registry remove script scripting text tutorial tweak tweets Twitter UAC updates User Account Control VBS VBScript vista volume Windows Windows 7 Windows Guru Windows Script Windows Script Host Windows Scripting Windows Vista Windows XP Word WScript wscript.exe WSH XP