Simple .bat question


  1. Posts : 4
    windows 7 home premium x64 service pack 1
       #1

    Simple .bat question


    Hi all,
    Does anybody happen to know what command I should be using in a batch file to open a file with a program other than the default for that extension? Or alternatively, as a workaround, how to set the default for a given extension in a batch file and then set it back again?
    Specifically I'm working with a program that has multiple .cfg files for when I'm doing various things, so I'm trying to make batch files to open the appropriate one at the appropriate time but want to leave notepad as the default program to open them for ease of editing.
    Thanks,
    Simon
      My Computer


  2. Posts : 72,050
    64-bit Windows 11 Pro for Workstations
       #2

    Hello Simon, and welcome to Seven Forums.

    You could use this in the BAT file to open a file with a supported program of your choice.

    start "Full path to .exe of program" "Full path of file with extension"


    For example, to open a .txt file in Wordpad.

    start "C:\Windows\write.exe" "C:\Users\(user-name)\My Documents\My text file.txt"


    Hope this helps, :)
    Shawn
      My Computer


  3. Posts : 4
    windows 7 home premium x64 service pack 1
    Thread Starter
       #3

    That's great, thank you very much.
      My Computer


  4. Posts : 72,050
    64-bit Windows 11 Pro for Workstations
       #4

    You're most welcome Simon. :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:37.
Find Us