How do you test if a window (by title) is already open from the command prompt?

ciso

In a batch file, I'm opening a window with a specific name like this:

@echo off    
start "my log" /D \logs\ /I powershell -nologo -noexit -command "$host.ui.RawUI.WindowTitle = 'My log'"; get-content logfile.log -wait

So the window title is "My log".

How do you run this command only if the window is not already open. Is there a bat file command to test for this? I'd rather not use a program or a powershell command, just a simple bat file cmd if possible.

Something like this:

@echo off    
if EXISTS window("My log") goto skip

start "my log" /D \logs\ /I powershell -nologo -noexit -command "$host.ui.RawUI.WindowTitle = 'My log'"; get-content logfile.log -wait

:skip
Serenity
@For /f "Delims=:" %A in ('tasklist /v /fi "WINDOWTITLE eq New Folder"') do @if %A==INFO echo Prog not running

More info on batch. Also see for /?.

&    seperates commands on a line.

&&    executes this command only if previous command's errorlevel is 0.

||    (not used above) executes this command only if previous command's errorlevel is NOT 0

>    output to a file

>>    append output to a file

<    input from a file

|    output of one command into the input of another command

^    escapes any of the above, including itself, if needed to be passed to a program

"    parameters with spaces must be enclosed in quotes

+ used with copy to concatinate files. E.G. copy file1+file2 newfile

, used with copy to indicate missing parameters. This updates the files modified date. E.G. copy /b file1,,

%variablename% a inbuilt or user set environmental variable

!variablename! a user set environmental variable expanded at execution time, turned with SelLocal EnableDelayedExpansion command

%<number> (%1) the nth command line parameter passed to a batch file. %0 is the batchfile's name.

%* (%*) the entire command line.

%<a letter> or %%<a letter> (%A or %%A) the variable in a for loop. Single % sign at command prompt and double % sign in a batch file.


.
--

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to open the command prompt from a file

From Dev

How do you open SourceTree from the command line?

From Dev

How does one keep Alfred 2 from opening and entering your Terminal command in a new window when Terminal is already open?

From Dev

how do you get the title of the active window using autohotkey

From Dev

How do you get the Windows Console \ Command Prompt to display color?

From Dev

How do you open a new JPanel window on a click of a button?

From Dev

How to run particular protractor test case from command prompt

From Dev

How do you re-position an open window in wxpython

From Dev

How to open command prompt as administrator from address bar

From Dev

How do you write to a command prompt in Java?

From Dev

What does it mean to open an "Anaconda" prompt distinct from command prompt and how to?

From Dev

How to open a new window from dock if it's already running in OSX

From Dev

How do you open the command prompt in Windows 7 with a shortcut key?

From Dev

How do I open a "custom" command prompt in Windows?

From Dev

How to open Command Prompt from Command Prompt

From Dev

How do you view the labeling of the test set with GenericAcrfTui from the command line?

From Dev

How do you allow only one instance of an inherited window to be open?

From Dev

How do you set a variable to the value returned from prompt('...')?

From Dev

How to restart Command Prompt from Command Prompt

From Dev

How do I open a program via the command prompt in Windows 8?

From Dev

How do I change "Open with Powershell" to "Open with Command Prompt" when shift-rightclicking in Explorer?

From Dev

How do you add a reference to a program in the Windows command prompt?

From Dev

How do you set and call a path variable in command prompt?

From Dev

How do you open a new JPanel window on a click of a button?

From Dev

How do you make an animation with the title of a Tkinter window?

From Dev

How do I open a new command line window from an sh script and then pass in multiple commands

From Dev

How do you open a second window in OneNote 2019 / Windows 10?

From Dev

how to prompt "open file window" from command prompt in java?

From Dev

how do I test if a refcursor is already open in plpgsql

Related Related

  1. 1

    How to open the command prompt from a file

  2. 2

    How do you open SourceTree from the command line?

  3. 3

    How does one keep Alfred 2 from opening and entering your Terminal command in a new window when Terminal is already open?

  4. 4

    how do you get the title of the active window using autohotkey

  5. 5

    How do you get the Windows Console \ Command Prompt to display color?

  6. 6

    How do you open a new JPanel window on a click of a button?

  7. 7

    How to run particular protractor test case from command prompt

  8. 8

    How do you re-position an open window in wxpython

  9. 9

    How to open command prompt as administrator from address bar

  10. 10

    How do you write to a command prompt in Java?

  11. 11

    What does it mean to open an "Anaconda" prompt distinct from command prompt and how to?

  12. 12

    How to open a new window from dock if it's already running in OSX

  13. 13

    How do you open the command prompt in Windows 7 with a shortcut key?

  14. 14

    How do I open a "custom" command prompt in Windows?

  15. 15

    How to open Command Prompt from Command Prompt

  16. 16

    How do you view the labeling of the test set with GenericAcrfTui from the command line?

  17. 17

    How do you allow only one instance of an inherited window to be open?

  18. 18

    How do you set a variable to the value returned from prompt('...')?

  19. 19

    How to restart Command Prompt from Command Prompt

  20. 20

    How do I open a program via the command prompt in Windows 8?

  21. 21

    How do I change "Open with Powershell" to "Open with Command Prompt" when shift-rightclicking in Explorer?

  22. 22

    How do you add a reference to a program in the Windows command prompt?

  23. 23

    How do you set and call a path variable in command prompt?

  24. 24

    How do you open a new JPanel window on a click of a button?

  25. 25

    How do you make an animation with the title of a Tkinter window?

  26. 26

    How do I open a new command line window from an sh script and then pass in multiple commands

  27. 27

    How do you open a second window in OneNote 2019 / Windows 10?

  28. 28

    how to prompt "open file window" from command prompt in java?

  29. 29

    how do I test if a refcursor is already open in plpgsql

HotTag

Archive