Script to open text file.

9 views
Skip to first unread message

Ivan Denisovich

unread,
Apr 12, 2021, 1:59:38 PM4/12/21
to
I have always checked a command line on the CMD black screen prior to inserting it into a .bak file, and it has always worked.

Well, I ran into a problem with the script to open a text file, say

"C:\users\myfile.txt"

This works when used on the black screen, but not when placed into a .bak file, which is then executed. The file does not open.

Any thoughts on what the problem is? Thanks for all suggestions.

John Dulak

unread,
Apr 12, 2021, 2:59:06 PM4/12/21
to
Ivan:

I think that should be a file with a ".BAT" extension (as in BATCH) file.

John

--
\\\||///
------------------o000----(o)(o)----000o----------------
----------------------------()--------------------------
'' Madness takes its toll - Please have exact change. ''

Ivan Denisovich

unread,
Apr 12, 2021, 4:29:23 PM4/12/21
to
On Monday, April 12, 2021 at 1:59:06 PM UTC-5, John Dulak wrote:
> On 4/12/2021 1:59 PM, Ivan Denisovich wrote:
> > I have always checked a command line on the CMD black screen prior to inserting it into a .bak file, and it has always worked.
> >
> > Well, I ran into a problem with the script to open a text file, say
> >
> > "C:\users\myfile.txt"
> >
> > This works when used on the black screen, but not when placed into a .bak file, which is then executed. The file does not open.
> >
> > Any thoughts on what the problem is? Thanks for all suggestions.
> >
> Ivan:
>
> I think that should be a file with a ".BAT" extension (as in BATCH) file.
>

With my apologies John, I miswrote. The file is, in fact, ".bat". Any thoughts about the problem I described?

Thanks for posting, and sorry again for my mistake.

John Dulak

unread,
Apr 12, 2021, 5:17:00 PM4/12/21
to
On 4/12/2021 1:59 PM, Ivan Denisovich wrote:
Ivan:

If the filename has spaces or odd characters in it it should be enclosed in
quotation marks. Other than that I can't think of anything. IIRC there used to
be a Usenet group devoted to batch files. You might get better answers there.

JJ

unread,
Apr 13, 2021, 5:20:41 AM4/13/21
to
On Mon, 12 Apr 2021 13:29:21 -0700 (PDT), Ivan Denisovich wrote:
>
> With my apologies John, I miswrote. The file is, in fact, ".bat". Any
> thoughts about the problem I described?
>
> Thanks for posting, and sorry again for my mistake.

It could probably due to broken file type association. Check with the ASSOC
and FTYPE commands. e.g.

C:\>assoc .bat
.bat=batfile

C:\>ftype batfile
batfile="%1" %*

Ivan Denisovich

unread,
Apr 13, 2021, 3:44:53 PM4/13/21
to
I will try both suggestions. Many thanks to you & john for your help.
Reply all
Reply to author
Forward
0 new messages