Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Associating Files with VBS 1

Status
Not open for further replies.

Norm11

Programmer
Jul 30, 2007
12
US
Hello!

I'm new here, so I apologize if this has been posted in the past.

I want to be able to associate a file type with a VB script I've written. In other words, when my users double click a custom file type (say, .XYZ), my VB Script launches and "consumes" the contents of the file--sort of like how .DOC files are associated with Word. When you double click a .DOC file, Word automatically fires up and displays the file.

Here's the problem--each time I try to associate the file with my script, Windows XP keeps telling me that the file is not a valid Win32 application.

I would think SOMEONE has done this before, but all my Google searches have come up empty.

Any ideas?

Thanks,
Norm
 
>In other words, when my users double click a custom file type (say, .XYZ), my VB Script launches and "consumes" the contents of the file
How do you mean by "consumes". If you mean that the vbscript will be satisfied by taking in the path pointing to the file abc.xyz, you can surely do like associating any file type is doing.

In the explorer,
[1] Click out tab Tools(T) |Options (O) |File Types
[2] If .xyz is never existing, create one.
[3] Click on the file type .xyz and then Advnace (V) button.
[4] Click the "Add" button.
[5] Give the action some name in the upper textbox.
[6] Enter the command line in the second textbox. Something like this (here use wscript.exe, you can sure use cscript.exe as well if you want to). Furnish fullpath if necessary. (If space exists, preferrably use shortname.)
[tt] wscript.exe c:\yourutility\utility.vbs "%1"[/tt]
[7] Click all the accepts etc...
[8] If you want the action taking place simply by double-click, you make the action [6] default action (there is a button) before doing [7]. I would recommend not to make it default. For non-default action, right-click on the file type .xyz and choose the action.

This is to establish the need through gui. It is not impossible to do it via script, but that depends on your skill: no reason to do it for a one-time thing.
 
Thank you! I did not realize I needed to precede my script name with wscript.exe. That did the trick! Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top