Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Open txt file using default program on Windows

by rpnoble419 (Pilgrim)
on May 31, 2013 at 23:50 UTC ( [id://1036352]=note: print w/replies, xml ) Need Help??


in reply to Open txt file using default program on Windows

Always check what program is assigned as the default text program. If its not Notepad, then assign it

  • Comment on Re: Open txt file using default program on Windows

Replies are listed 'Best First'.
Re^2: Open txt file using default program on Windows
by Old_Gray_Bear (Bishop) on Jun 01, 2013 at 01:56 UTC
    Not on MY Machine, you don't.

    Programs that try to modify my configuration without asking probably have other socially unacceptable habits as well.

    ----
    I Go Back to Sleep, Now.

    OGB

Re^2: Open txt file using default program on Windows
by elef (Friar) on Jun 01, 2013 at 10:56 UTC
    I'm going to go ahead and assume that by "assign it", you meant "open the file in Notepad" and not "edit the registry to associate txt files with Notepad". Even if that assumption is correct, no. Just no. Don't override people's preferences for text editors. If the guy wants to view txt files in Notepad++ instead of Notepad (and who can blame him), then let him view his txt files in Notepad++.

    I use system ("\"$filepath/log.txt\"") to open log files in case of errors. It seems to work OK.
Re^2: Open txt file using default program on Windows
by perl-diddler (Chaplain) on Jun 01, 2013 at 02:03 UTC
    Well... you got half it right... if there is no program associated with the ".txt" extension, you need to bring up some other default (or ask the user), but I wouldn't go changing their registry unless you ask them if then want you to fix it....
Re^2: Open txt file using default program on Windows
by rpnoble419 (Pilgrim) on Jun 01, 2013 at 15:07 UTC

    I should know better then to answer these when I'm tired.

    As he has permission to install his program and Perl with it, I assume (we all know where that can lead) I hope he has the smarts to ask the end user first if its ok to make any changes. But a better solution would be to do the following

    system ('start c:\windows\notepad.exe filename.txt');

    Now he will always get Notepad to open the text file.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1036352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-19 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found