Batch line to display readonly text in a window ?

31 views
Skip to first unread message

John Stockton

unread,
Apr 14, 2022, 10:05:40 AMApr 14
to
I use code like the following, in batch files running in a Command Prompt window, to display the content of a freshly-written plain-text file in a normal window. From there, I selectively copy'n'paste into a Command Prompt window.

set DIFF_TXT=%LOGDIR%\$ORPHANS.TXT
REM write to $orphans.txt
start iexplore.exe %DIFF_TXT%

I don't want to continue with Internet Explorer, as it is dying.

I could use Notepad, except that I want the content of the window to be unalterable (except by scrolling and resizing; being un-saveable is irrelevant)

I could use another browser, but I chose to use Internet Explorer because I never use it otherwise at that time and I therefore get a new on-top window.

So : is there another means of displaying, from within Batch, a file in a read-only window (required for Win 10, might be wanted in Win 7 or Win 11)?

Otherwise, how/can I create a suitable window/dialog, with copy'n'paste, using VBScript?

--
(c) John Stockton, near London, UK. Using Google Groups. |

Dallas

unread,
Apr 14, 2022, 12:32:25 PMApr 14
to
Interesting question!

Now i wonder that when iexplore.exe is retired as a name to invoke Internet Explorer with, will
iexplore.exe be a program to launch the currently marketed Microsoft browser ?

From
https://techcommunity.microsoft.com/t5/windows-it-pro-blog/internet-explorer-11-desktop-app-retirement-faq/ba-p/2366549
"
Will iexplore.exe be removed from devices?
No, but if a user tries to access it, they will be unable to open IE11 and will be redirected to
Microsoft Edge.
"



Kenny McCormack

unread,
Apr 14, 2022, 1:47:36 PMApr 14
to
In article <96fcfa8a-9948-4474...@googlegroups.com>,
John Stockton <dr.j.r....@gmail.com> wrote:
...
>I could use another browser, but I chose to use Internet Explorer because I never
>use it otherwise at that time and I therefore get a new on-top window.
>
>So : is there another means of displaying, from within Batch, a file in a
>read-only window (required for Win 10, might be wanted in Win 7 or Win 11)?
>
>Otherwise, how/can I create a suitable window/dialog, with
>copy'n'paste, using VBScript?

Invoking a browser just to display text is the proverbial overkill
(something about smashing ants with a sledgehammer). But you probably
already know that.

I suppose the overall goal is to avoid doing any programming, but it sure
doesn't seem like it would be very hard to knock something together in VB
or some variation thereof. I think there is even an example code for this
in the TCC (tiny C compiler) distro for Windows.

Or, you could use WSL and then use xmessage...

(That's how I do this sort of thing mostly nowadays, but, of course, under
Linux, not Windows)

--
Many North Koreans believe Kim-il-Sung is an "almighty god" who "created
the world" in seven days as a divine spirit millions of years ago, and
came to Earth as a human in 1912 as a messianic figure.

John Stockton

unread,
Apr 14, 2022, 6:34:31 PMApr 14
to
On Thursday, 14 April 2022 at 17:32:25 UTC+1, Dallas wrote:
> On 4/14/2022 9:05 AM, John Stockton wrote:

> > set DIFF_TXT=%LOGDIR%\$ORPHANS.TXT
> > REM write to $orphans.txt
> > start iexplore.exe %DIFF_TXT%
> >
> > I don't want to continue with Internet Explorer, as it is dying.

> From
> https://techcommunity.microsoft.com/t5/windows-it-pro-blog/internet-explorer-11-desktop-app-retirement-faq/ba-p/2366549
> "
> Will iexplore.exe be removed from devices?
> No, but if a user tries to access it, they will be unable to open IE11 and will be redirected to
> Microsoft Edge.
> "

In which case, I probably don't need to do anything.

However, I do have Notepad++ - and
"C:\Program Files\Notepad++\notepad++" -ro $rajesh.txt
does what I want (and in a better font!).

But I'll see what I can get using something like
CALL WScript new_prog.vbs $rajesh.txt

Thanks to both,

Marble2

unread,
Apr 14, 2022, 7:02:25 PMApr 14
to
John Stockton <dr.j.r....@gmail.com> wrote in
news:96fcfa8a-9948-4474...@googlegroups.com:
If you like your browser solution, rename the file with an html file
extension and try "start yourfile.html". It should open in your
default browser.

Dallas

unread,
Apr 14, 2022, 7:03:24 PMApr 14
to
On 4/14/2022 5:34 PM, John Stockton wrote:
> However, I do have Notepad++ - and
> "C:\Program Files\Notepad++\notepad++" -ro $rajesh.txt
> does what I want (and in a better font!).
>

I was thinking that you needed a solution that did not involve "not-provided" software like NP++
that you have to install.


Dallas

unread,
Apr 14, 2022, 7:21:27 PMApr 14
to
I have used VSCode for this purpose:

type $rajesh.txt | code -



Adam Lubszczyk

unread,
Apr 15, 2022, 6:49:57 AMApr 15
to
If You have a Total Commander try

....\TOTALCMD.EXE /s=l C:\PATH\FILE.TXT


Adam

JJ

unread,
Apr 15, 2022, 6:52:23 AMApr 15
to
You can use HTML Application. The command line is pretty long, so it's in
Pastebin.

https://pastebin.com/GGSFdbG7

Dallas

unread,
Apr 15, 2022, 9:12:17 AMApr 15
to
On 4/14/2022 6:21 PM, Dallas wrote:
> I have used VSCode for this purpose:
> dir | code -
>

Adding a -n switch creates a new window for the VSCode process.

dir | code - -n

Now, I want to find a way to keep VSCode from blocking the cmd.exe process.


John Stockton

unread,
Apr 15, 2022, 10:06:07 AMApr 15
to
On Friday, 15 April 2022 at 00:02:25 UTC+1, Marble2 wrote:
> John Stockton <dr.j.r....@gmail.com> wrote in
> news:96fcfa8a-9948-4474...@googlegroups.com:
> > I use code like the following, in batch files running in a Command
> > Prompt window, to display the content of a freshly-written
> > plain-text file in a normal window. From there, I selectively
> > copy'n'paste into a Command Prompt window.


> If you like your browser solution, rename the file with an html file
> extension and try "start yourfile.html". It should open in your
> default browser.

I do not want it to open in an already-running application - using a new one makes it much easier to find the new window.

John Stockton

unread,
Apr 15, 2022, 11:00:29 AMApr 15
to
Working Notepad++ is better that not-working IE11. But if start iexplore.exe %DIFF_TXT% opens Edge which opens %DIFF_TXT% as ReadOnly, then I actually need to do nothing. Except that Microsoft might "upgrade" Edge to be a page editor ...

In my PCs, Notepad++ is installed already <g>. But I'd prefer something already in Windows. If Notepad or Wordpad understood ReadOnly, I'd use it.

An additional requirement is compatibility with 64-bit Windows. I have the late Vernon Buerg's LIST, but cannot run it.

If I end up writing something, I might call it MIKADO. My system would automatically transfer it with my batch file.

Dallas

unread,
Apr 15, 2022, 12:45:32 PMApr 15
to
I loved Vernon Buerg's LIST program.

For a while I created "bridge" scripts to allow me to use those older utilities even if all they
understood were 8.3 formatted file names. But when I switched to a 64-bit Windows I had to
regretfully leave them behind and implement PowerShell versions of some of them.

Dallas

unread,
Apr 15, 2022, 12:46:23 PMApr 15
to
On 4/15/2022 10:00 AM, John Stockton wrote:
Do you have VSCode installed?


Dallas

unread,
Apr 15, 2022, 1:57:53 PMApr 15
to
On 4/14/2022 5:34 PM, John Stockton wrote:
> However, I do have Notepad++ - and
> "C:\Program Files\Notepad++\notepad++" -ro $rajesh.txt
> does what I want (and in a better font!).
>

Have you ever tried using the
-multiInst
parameter to Notepad++ ?

I am testing it, but not quite sure what to expect.

John Stockton

unread,
Apr 16, 2022, 8:53:22 AMApr 16
to
I was unaware of it. It seems to duplicate a pre-existing Notepad++ window (if any) then open a named file (if any) in a new tab in one of the copies. If a file is open in more than one window, changes are not duplicated in the other.

Dallas

unread,
Apr 16, 2022, 10:00:40 AMApr 16
to
Thanks!

I am still playing with it, but getting inconsistent results.

I had hoped that it would open a new window with only one tab for the file I want to edit.

But sometimes it also has a tab a file I previously had open.

- Dallas

John Stockton

unread,
Apr 16, 2022, 5:54:31 PMApr 16
to
Press the ? at the top of Notepad++, then press Command Line Arguments ...
Site https://npp-user-manual.org/ says a great deal more.

I now have a batch file :

@echo MIKADO.BAT (c) JRS 2022-04-16+
:: Ko-Ko : "I've Got a Little List" - The Mikado - Gilbert and Sullivan
:: REM @start iexplore.exe %1
@call "C:\Program Files\Notepad++\notepad++" -ro -alwaysOnTop -nosession %1
@echo MIKADO.BAT ends.
:: End.

The Notepad++ line displays the text as I want it - - -
but MIKADO.BAT annoyingly does not resume until I close Notepad++ . ???

Kerr-Mudd, John

unread,
Apr 16, 2022, 6:09:55 PMApr 16
to
That's easily solved. Enforcing a copyright is a whole different matter. Good Luck.

--
Bah, and indeed Humbug.

Dallas

unread,
Apr 16, 2022, 8:42:17 PMApr 16
to
On 4/16/2022 4:54 PM, John Stockton wrote:
> Press the ? at the top of Notepad++, then press Command Line Arguments ...
> Site https://npp-user-manual.org/ says a great deal more.
>
> I now have a batch file :
>
> @echo MIKADO.BAT (c) JRS 2022-04-16+
> :: Ko-Ko : "I've Got a Little List" - The Mikado - Gilbert and Sullivan
> :: REM @start iexplore.exe %1
> @call "C:\Program Files\Notepad++\notepad++" -ro -alwaysOnTop -nosession %1
> @echo MIKADO.BAT ends.
> :: End.
>
> The Notepad++ line displays the text as I want it - - -
> but MIKADO.BAT annoyingly does not resume until I close Notepad++ . ???
>
> --
> (c) John Stockton, near London, UK. Using Google Groups. |


I am trying to find a way to eliminate that block-until-close with VSCode as well.

I know how to code around it using PowerShell, but not cmd.exe



Thomas Langer

unread,
Apr 17, 2022, 9:24:25 AMApr 17
to

Am 16.04.2022 um 23:54 schrieb John Stockton:
>> --
>> (c) John Stockton, near London, UK. Using Google Groups. |
> Thanks!
>
> I am still playing with it, but getting inconsistent results.
>
> I had hoped that it would open a new window with only one tab for the file I want to edit.
>
> But sometimes it also has a tab a file I previously had open.
>
> - Dallas

to resume your batch file after starting notepad++ replace original line
of code
@call "C:\Program Files\Notepad++\notepad++" -ro -alwaysOnTop
-nosession %1

with
start "" "C:\Program Files\Notepad++\notepad++" -ro -alwaysOnTop
-nosession %1


Regards
Thomas Langer

John Stockton

unread,
Apr 17, 2022, 5:04:49 PMApr 17
to
YES - but I don't see why adding a blank title has the desired effect !

Thanks,

Kenny McCormack

unread,
Apr 17, 2022, 5:34:00 PMApr 17
to
In article <94411f5d-28cd-42e1...@googlegroups.com>,
John Stockton <dr.j.r....@gmail.com> wrote:
>On Sunday, 17 April 2022 at 14:24:25 UTC+1, Thomas Langer wrote:
>> Am 16.04.2022 um 23:54 schrieb John Stockton:
>
>> to resume your batch file after starting notepad++ replace original line
>> of code
>> @call "C:\Program Files\Notepad++\notepad++" -ro -alwaysOnTop
>> -nosession %1
>> with
>> start "" "C:\Program Files\Notepad++\notepad++" -ro -alwaysOnTop
>> -nosession %1
>
>YES - but I don't see why adding a blank title has the desired effect !

It is a bug^H^H^Hmisfeature of the "start" command in CMD.EXE.

If you don't put the "" in there, it will just open a(nother) CMD window.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/ThePublicGood

Dallas

unread,
Apr 17, 2022, 7:32:01 PMApr 17
to
You are not alone in being confused by the behavior of the START command.

The instance when I have to specify a title is when the command/program string contains spaces and
I need to wrap that string with double quotes.



Thomas Langer

unread,
Apr 19, 2022, 1:51:39 AMApr 19
to
The command START without the argument /WAIT starts a program in a new
process. Using START instead of CALL gives the desired result.

In earlier Windows versions START seemed to have a bug if the argument
"TITLE" had been omitted. To work around this bug it became usual to
call START with an empty "TITLE", but in current versions START does run
without "TITLE", tested with [version 10.0.19043.1645]

As I do not know your environment I gave you the syntax known as to work
for sure.

Dallas

unread,
Apr 21, 2022, 1:27:38 PMApr 21
to
In the particular case of

start "" "C:\Program Files\Notepad++\notepad++" -ro -alwaysOnTop

It is the space character in "Program Files" that makes it necessary to specify a Title and the
smallest Title is the empty string.



Reply all
Reply to author
Forward
0 new messages