Need to change 'open with' file from command line

P

PD

I'm putting a batch together to be distributed and need to
change the 'open with' application for the file type.
The 'ASSOC' command only takes care of the file type...in
this case I'm changing the file type to 'txtfile'.
What I need to do FROM THE COMMAND LINE is to have these
particular files open with WordPad, not Notepad.
If I go through the 'Folder Options' GUI to do this it is
no problem at all, but I don't know how to do this from
the command line.
Any ideas or suggestions?
 
M

Matthias Tacke

PD said:
I'm putting a batch together to be distributed and need to
change the 'open with' application for the file type.
The 'ASSOC' command only takes care of the file type...in
this case I'm changing the file type to 'txtfile'.
What I need to do FROM THE COMMAND LINE is to have these
particular files open with WordPad, not Notepad.
If I go through the 'Folder Options' GUI to do this it is
no problem at all, but I don't know how to do this from
the command line.
Any ideas or suggestions?

In the help of assoc there are references to ftype. See
ftype /?

@echo off
for /F "tokens=*" %%A in ('dir /B /S %ProgramFiles%\wordpad.exe') do (
echo ftype txtfile=%%A %%1)

if the ftype line seems ok remove the echo

HTH
 
M

Matthias Tacke

PD said:
I'm putting a batch together to be distributed and need to
change the 'open with' application for the file type.
The 'ASSOC' command only takes care of the file type...in
this case I'm changing the file type to 'txtfile'.
What I need to do FROM THE COMMAND LINE is to have these
particular files open with WordPad, not Notepad.
If I go through the 'Folder Options' GUI to do this it is
no problem at all, but I don't know how to do this from
the command line.
Any ideas or suggestions?

This one stores the old ftype:

==File:assocftype.cmd========2004-01-23=16:41:[email protected]===
01.@echo off & setlocal EnableExtensions DisableDelayedExpansion
02.::save old ftype in restore_txtfile.cmd
03.set /P ="ftype "<NUL>restore_txtfile.cmd
04.ftype txtfile>>restore_txtfile.cmd
05.for /F "tokens=*" %%A in ('dir /B /S %ProgramFiles%\wordpad.exe') do (
06.ftype txtfile=%%A %%1
07.echo Now set: ftype txtfile=%%A %%1
08.)
09.echo The old one is stored. To undo issue on the cmdline
10.echo restore_txtfile.cmd
==:EOF:assocftype.cmd========2004-01-23=16:41:[email protected]===
 
M

Matthias Tacke

This worked great! Thanks!

Do you also know the cmd line for assigning an icon?
The icon should follow the associated porgram (with a delay)

Links/shortcuts may have to be recreated. This is also
possible from the command line. Search google for
shortcut.exe / makescut.exe

PS: I wrote this answer already on a different pc. seems
it is lost. Or it doubles now :)

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top