5

This question is a natural follow up to How to run a batch file without launching a "command window"?

One can associate for example .txt files with Wordpad by opening the Properties dialog of a txt file and pressing the Change button next to "Opens with..." and choosing Wordpad. If I do the same with a VBScript file (rather than Wordpad), that is, if I associate .txt files with the VBscript and try to open the associated file (the txt file), Windows shows a pop up saying

This app can't run on your PC ...

The full quote and the screenshot is exactly the same as one in this thread

I suspect this error message may be due to some kind of security feature of Windows 8 to prevent users from being tricked into running bad scripts, but the vbs script is created by myself on the same machine, and I wonder if there is a way say "I wrote this. You can trust this script." to Windows. The script runs fine if I run it directly (by double clicking or tapping on it), or if I drag and drop a txt file to the script.

Jisang Yoo
  • 447
  • 1
  • 5
  • 13

2 Answers2

3

I also have a problem that requires a file type to be opened through explorer with a script (vbscript) and have found a solution, you just need to edit the registry.

  1. Go to the following registry key for your filetype: HKCR\YourfileType\Shell\Open\Command
  2. Edit the (Default) key and enter in something like this string

    C:\Windows\System32\cscript.exe "C:\PathToyourScript\Script.vbs" "%1"

The %1 passes the filename to script as a parameter

This is working well for my needs but you may need to test it. Best of Luck!

Julius
  • 31
1

Instead of using your VBscript file, try using Nirsoft FileTypesMan to modify the command line arguments the .txt and .foo files use when launching emacs.exe

This question is similar to Adding default command line options when opening a particular filetype

GrossT
  • 1,099