Need to change 'open with' file from command line

  • Thread starter Thread starter PD
  • Start date Start date
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?
 
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
 
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]===
 
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
 
Back
Top