If you want to prevent certain applications, such as a Visual Basic Script in an e-mail attachment, from running automatically, you can change the default application handler for that specific extension. Some candidate extensions are:
.jse
.js
.reg
.vbs
.vbe
.wsf
To cause these extensions to open in Notepad instead of their current default:
1. Open a CMD prompt and type:
assoc .extension
Example: assoc .vbs
2. This will display a line in the following format:
.extension=FileTypeHandler
Example: .vbs=VBSFile
3. Type:
ftype FileTypeHandler
Example: ftype VBSFile
4. This will display a line in the following format:
FileTypeHandler=<path>\Program.exe "%1"
Example: vbsfile=%SystemRoot%\System32\WScript.exe "%1" %*
5. Change the executable to Notepad by typing:
ftype FileTypeHandler=%SystemRoot%\System32\Notepad.exe "%1"
Example: ftype VBSFile=%SystemRoot%\System32\Notepad.exe "%1" %*
NOTE: You may wish to export the registry entries involved, before making these changes, so that they can easily to restored. To do so:
regedit /e <Path>\FileTypeHandler.reg "HKEY_CLASSES_ROOT\FileTypeHandler\Shell\Open\command"
Example: regedit /e c:\VBSFile.reg "HKEY_CLASSES_ROOT\VBSFile\Shell\Open\command"
NOTE: Repeat these steps for each extension that you wish to prevent from running automatically.
NOTE: Once you know the FileTypeHandlers involved, you can do this in a batch:
regedit /e c:\VBSFile.reg "HKEY_CLASSES_ROOT\VBSFile\Shell\Open\command"
ftype VBSFile=%SystemRoot%\System32\Notepad.exe "%1" %*