Closing command prompt windows.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Closing command prompt windows.

#16 Post by YukoValis » 04 Mar 2019 10:16

I'm so sorry. I got pretty sick and bedridden. So I was out of work for a few days. : ( My apologies.
Anyway, yeah only the tracert gets changed to Observation. Saved a pic
Attachments
yhrthsftghsftg.jpg
yhrthsftghsftg.jpg (136.26 KiB) Viewed 7306 times

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Closing command prompt windows.

#17 Post by aGerman » 04 Mar 2019 10:26

Seems to be the behavior on Win7 then. Since I only have access to Win10 machines I can't test it anymore. However, the only thing you have to do is to update the filter of TASKKILL (or FINDSTR in my former command line) according to your window title. You could have already done it weeks ago.

Steffen

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Closing command prompt windows.

#18 Post by YukoValis » 04 Mar 2019 10:35

or I could just change the kill command to ping instead of observation and kill all the ping commands >.< I'm an idiot. Thank you, that command does work.

One quick question though before I stop bugging you lol.
Is there any way to move the "press any button" window like the others? if not that is fine, since I can just move the others out of the way.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Closing command prompt windows.

#19 Post by aGerman » 04 Mar 2019 11:21

Something like that

Code: Select all

%start% "cmd /s /q /d /c ^"^"mode con cols=70 lines=25^&^(pause^>nul^|set /p ^"^"^=Press any key to close monitoring windows ...^"^"^)^&echo^(^&taskkill /f /t /fi ^"^"WINDOWTITLE eq Observation*^"^" /im cmd.exe^"^""    0  342
But it doesn't work yet. I get a wrong syntax error for taskkill. Escaping is getting quite complicated.

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Closing command prompt windows.

#20 Post by YukoValis » 04 Mar 2019 11:44

If it helps, this is the working command before the resizes and position hits.

start "Close Observations" /min cmd /s /q /d /c "pause>nul|set /p "=Press any key on this window to close ping windows ..."&echo(&taskkill /f /t /fi "WINDOWTITLE eq ping*" /im cmd.exe"

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Closing command prompt windows.

#21 Post by aGerman » 04 Mar 2019 11:48

No. It's not a matter of the window title but of escape sequences that are required to pass and process the command line in the JScript section.

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Closing command prompt windows.

#22 Post by YukoValis » 04 Mar 2019 11:53

I found an error that flashes right away.

Did I screw it up?

%start% "cmd /s /q /d /c ^"^"mode con cols=70 lines=25^&^(pause^>nul^|set /p ^"^"^=Press any key on this window to close ping windows ...^"^"^)^&echo^(^&taskkill /f /t /fi ^"^"WINDOWTITLE eq ping*^"^" /im cmd.exe^"^"" 1158 684
Attachments
afgdfgsdfgd.jpg
afgdfgsdfgd.jpg (37.79 KiB) Viewed 7298 times

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Closing command prompt windows.

#23 Post by aGerman » 04 Mar 2019 12:27

aGerman wrote:
04 Mar 2019 11:21
I get a wrong syntax error for taskkill
:wink:
Just try to fix the escaping. Maybe you'll find the culprit...

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Closing command prompt windows.

#24 Post by YukoValis » 04 Mar 2019 12:59

Hmm. I'm not familiar with escaping. In fact this is the first time I heard the term. ok so I looked at all the ^'s there are an odd number, but that seems to work on all the other lines. There is an even number of "" so I don't think that is the case. I looked at the working line and tried to compare it to this not working line. All the * and &'s seem spot on. Taking out the eq that gives the error message makes ping the error message, so he has to be something before that. All the switches seem the same, unless I need a /k? Adding that just yells at me. It is weird seeing a ( without a ), but the working code has that too. Is it because it is missing the "Close Observations" /min. Because adding that causes it to not even show up.
Any more hints?

I also noticed that it still calls tracert "observation" despite that part taken out...
The working code seems to not use set, but the not working code makes use of set. I'm not sure how that works. I took a screenshot of the working one, and it seems to turn all the pings into observations.

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Closing command prompt windows.

#25 Post by YukoValis » 05 Mar 2019 10:31

Ok I've been pouring over this script for the last 2 hours inbetween calls. I'd added and subtracted here and there. I've studied it closely with the one that works. I don't think I know enough to know what the issue is. I feel like I'm missing something very simple. In that time I did learn how to did the script part, and have the line to call the script. That was neat.
This just keeps failing and saying eq is not a valid argument.

@if (@a)==(@b) @end /*
@echo off &setlocal
set "start=cscript //nologo //e:jscript %~fs0 "

set /p number="4 digit store number? "?

%start% "cmd /s /q /d /c ^"^"mode con cols=70 lines=25 ^&^(pause^>nul^|set /p ^"^"^=Press any key on this window to close ping windows ...^"^"^)^&echo^(^&taskkill /f /t /fi ^"^"WINDOWTITLE eq ping*^"^" /im cmd.exe^"^"" 1158 684

%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& ping str%number% -t ^"^"" 0 0
%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& ping str%number%vma -t ^"^"" 0 342
%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& ping str%number%vmb -t ^"^"" 0 684
%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& tracert str%number% ^"^"" 579 0
%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& ping str%number%sa -t ^"^"" 579 342
%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& ping str%number%sd -t ^"^"" 579 684
%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& ping sw%number%a -t ^"^"" 1158 0
%start% "cmd /s /q /d /k ^"^"mode con cols=70 lines=25 ^& ping sw%number%b -t ^"^"" 1158 342

goto :eof */
var objWMIService = GetObject('winmgmts:\\\\.\\root\\CIMV2'),
objProcess = objWMIService.Get('Win32_Process'),
objParam = objProcess.Methods_('Create').InParameters.SpawnInstance_(),
objStartup = objWMIService.Get('Win32_ProcessStartup').SpawnInstance_();
objStartup.X = WScript.Arguments(1);
objStartup.Y = WScript.Arguments(2);
objStartup.Title = 'Observation';
objParam.Properties_.Item('CommandLine').Value = WScript.Arguments(0);
objParam.Properties_.Item('ProcessStartupInformation').Value = objStartup;
objWMIService.ExecMethod('Win32_Process', 'Create', objParam);

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Closing command prompt windows.

#26 Post by aGerman » 05 Mar 2019 10:55

I also tried a lot but still don't know how to get it working.

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Closing command prompt windows.

#27 Post by YukoValis » 05 Mar 2019 12:12

Oooh. and here I thought you were testing me lol

The working one is this
start "Close Observations" /min cmd /s /q /d /c "pause>nul|set /p "=Press any key on this window to close ping windows ..."&echo(&taskkill /f /t /fi "WINDOWTITLE eq ping*" /im cmd.exe"

The one I wanted to work is
%start% "cmd /s /q /d /c ^"^"mode con cols=70 lines=25 ^&^(pause^>nul^|set /p ^"^"^=Press any key on this window to close ping windows ...^"^"^)^&echo^(^&taskkill /f /t /fi ^"^"WINDOWTITLE eq ping*^"^" /im cmd.exe^"^"" 1158 684

For some reason, the one that works changes all the ping windows to "Observations" right as it closes it. But the one that doesn't work, well doesn't. I guess I'll just move the windows over.
Still thank you very much for everything you have done AGerman. I am grateful.

Post Reply