Solved I can't run bat and cmd files.


Please note that technically, there is no "Cmd window" or "PowerShell window". It's either a Console Host window or a Terminal window.

On Windows 10, by default, Cmd.exe and PowerShell.exe run in the Console Host (conhost.exe).

On Windows 11, by default, Cmd.exe and PowerShell.exe run in Windows Terminal (wt.exe).

Therefore, your batch file should, by default, run in a tabbed Terminal window and look like this:

View attachment 89340

If you run your batch file with "Run as Administrator", then it should open in Console Host and look like this:

View attachment 89343

The batch file will run the same regardless of the host. It's the same Cmd.exe interpreter either way.
True, but it does not show the results of the batch file operation - i.e. if I ping 10 times, they don't show. The only way to get it to work is open a command window and enter the command there.
 

My Computer My Computer

At a glance

Windows 11 Pro; 21H2, Build 22000.1281AMD Ryzen 3 3250 with Radeon Graphics8gbAMD Graphics
OS
Windows 11 Pro; 21H2, Build 22000.1281
Computer type
Laptop
Manufacturer/Model
Dell 3525
CPU
AMD Ryzen 3 3250 with Radeon Graphics
Memory
8gb
Graphics Card(s)
AMD Graphics
Sound Card
AMD high definition audio device; Realtek audio
Screen Resolution
1980x1020
True, but it does not show the results of the batch file operation - i.e. if I ping 10 times, they don't show. The only way to get it to work is open a command window and enter the command there.
That's unexpected. Try switching the default to Console Host and verify that it works correctly and then try switching it back to Terminal and see if the problem returns. Here's the tutorial for making the switch:

 

My Computer My Computer

At a glance

Windows 10/11
OS
Windows 10/11
Computer type
Laptop
Manufacturer/Model
Acer
That is a cmd window within Terminal.
I have no idea why that might appear when a batch file is being run from within File explorer. Mine do not. They appear as in my posted screenshots. You'll have to listen to Les about this topic.

I can't do a print screen any more, it opens snipping tool
That, as I understand it, is a setting somewhere.
I know nothing about it because I use a shortcut, script & a third-party utility for my screenshots [and it all allows delays and that's what allows me to capture dropdown menus].


Denis
 

My Computer My Computer

At a glance

Windows 11 Home x64 Version 25H2 Build 26200....
OS
Windows 11 Home x64 Version 25H2 Build 26200.8037
That's unexpected. Try switching the default to Console Host and verify that it works correctly and then try switching it back to Terminal and see if the problem returns. Here's the tutorial for making the switch:

Still does not show the results of the batch file in the window - turns off the batch file and opens a new command window:
Screenshot 2024-03-06 112524.png
 

My Computer My Computer

At a glance

Windows 11 Pro; 21H2, Build 22000.1281AMD Ryzen 3 3250 with Radeon Graphics8gbAMD Graphics
OS
Windows 11 Pro; 21H2, Build 22000.1281
Computer type
Laptop
Manufacturer/Model
Dell 3525
CPU
AMD Ryzen 3 3250 with Radeon Graphics
Memory
8gb
Graphics Card(s)
AMD Graphics
Sound Card
AMD high definition audio device; Realtek audio
Screen Resolution
1980x1020
That is a cmd window within Terminal.
I have no idea why that might appear when a batch file is being run from within File explorer. Mine do not. They appear as in my posted screenshots. You'll have to listen to Les about this topic.


That, as I understand it, is a setting somewhere.
I know nothing about it because I use a shortcut, script & a third-party utility for my screenshots [and it all allows delays and that's what allows me to capture dropdown menus].


Denis
I finally found the setting under Accessibility > Keyboard > Use the print screen key to open screen capture - turn off.
 

My Computer My Computer

At a glance

Windows 11 Pro; 21H2, Build 22000.1281AMD Ryzen 3 3250 with Radeon Graphics8gbAMD Graphics
OS
Windows 11 Pro; 21H2, Build 22000.1281
Computer type
Laptop
Manufacturer/Model
Dell 3525
CPU
AMD Ryzen 3 3250 with Radeon Graphics
Memory
8gb
Graphics Card(s)
AMD Graphics
Sound Card
AMD high definition audio device; Realtek audio
Screen Resolution
1980x1020
On Windows 11, by default, Cmd.exe and PowerShell.exe run in Windows Terminal (wt.exe).
If I right-click on the Start menu & select PowerShell, I go straight to a PS window
Start, PS, PS window - Win11.png


Denis
 

My Computer My Computer

At a glance

Windows 11 Home x64 Version 25H2 Build 26200....
OS
Windows 11 Home x64 Version 25H2 Build 26200.8037
Still does not show the results of the batch file in the window - turns off the batch file and opens a new command window
Correct.
It is doing what your chosen commands have told it to do.
- The Start cmd opens the second window.
- The pinging all happens in the second window.
- There are no further actions in the first window other than proceeding to the pause line.


And, as I said before, I do not know why you are using a Start command. It appears to me to be unproductive and it complicates the picture.


Denis
 

My Computer My Computer

At a glance

Windows 11 Home x64 Version 25H2 Build 26200....
OS
Windows 11 Home x64 Version 25H2 Build 26200.8037
LesFerch said:
On Windows 11, by default, Cmd.exe and PowerShell.exe run in Windows Terminal (wt.exe).
Only if this is selected as Default Terminal Application, which is not on the system below:

Screenshot 2024-03-06 180613.jpg
 

My Computers My Computers

  • At a glance

    All Branches but ReleaseAMD Ryzen 7 7735HS 3200-4500 Mhz 8 cores x 232 GB DDR5Radeon Graphic / NVIDIA GeForce RTX 4060 8 GB...
    OS
    All Branches but Release
    Computer type
    Laptop
    Manufacturer/Model
    Acer Nitro ANV15-51
    CPU
    AMD Ryzen 7 7735HS 3200-4500 Mhz 8 cores x 2
    Motherboard
    Sportage_RBH
    Memory
    32 GB DDR5
    Graphics Card(s)
    Radeon Graphic / NVIDIA GeForce RTX 4060 8 GB GDDR6
    Sound Card
    AMD/Realtek(R) Audio
    Monitor(s) Displays
    Integrated Monitor (15.3"vis)
    Screen Resolution
    FHD 1920X1080 16:9 144Hz
    Hard Drives
    KINGSTON OM8SEP4512Q-AA 1TB
    Western Digital 256GB
    PSU
    19V DC 6.32 A 120 W
    Cooling
    Dual Fans
    Mouse
    MS Bluetooth
    Internet Speed
    Fiber 1GB Cox -us & 1GB Orange-fr
    Browser
    Edge Canary- Firefox Nightly-Chrome Dev-Chrome Dev
    Antivirus
    Windows Defender
  • At a glance

    Windows 11 BetaAMD A9-94208 GB of DDR4AMD Radeon R5
    Operating System
    Windows 11 Beta
    Computer type
    Laptop
    Manufacturer/Model
    Asus X751BP
    CPU
    AMD A9-9420
    Memory
    8 GB of DDR4
    Graphics card(s)
    AMD Radeon R5
    Screen Resolution
    1600x900
    Hard Drives
    Seagate 1 TB

My Computer My Computer

At a glance

Windows 11 Home x64 Version 25H2 Build 26200....
OS
Windows 11 Home x64 Version 25H2 Build 26200.8037
  • Like
Reactions: OAT
Found a way to keep the results window open: start "" cmd /k ping -n 3 192.168.1.70

But that is not the answer because the .bat starts in one window and then switches to another one for the results so that there are two windows open.
 

My Computer My Computer

At a glance

Windows 11 Pro; 21H2, Build 22000.1281AMD Ryzen 3 3250 with Radeon Graphics8gbAMD Graphics
OS
Windows 11 Pro; 21H2, Build 22000.1281
Computer type
Laptop
Manufacturer/Model
Dell 3525
CPU
AMD Ryzen 3 3250 with Radeon Graphics
Memory
8gb
Graphics Card(s)
AMD Graphics
Sound Card
AMD high definition audio device; Realtek audio
Screen Resolution
1980x1020
Finally the answer - simply remove "start" from the command as I have always used in other versions of windows:

Before:
start "" cmd /k ping -n 3 192.168.1.70
Pause

After:
cmd /k ping -n 3 192.168.1.70
Pause
 

My Computer My Computer

At a glance

Windows 11 Pro; 21H2, Build 22000.1281AMD Ryzen 3 3250 with Radeon Graphics8gbAMD Graphics
OS
Windows 11 Pro; 21H2, Build 22000.1281
Computer type
Laptop
Manufacturer/Model
Dell 3525
CPU
AMD Ryzen 3 3250 with Radeon Graphics
Memory
8gb
Graphics Card(s)
AMD Graphics
Sound Card
AMD high definition audio device; Realtek audio
Screen Resolution
1980x1020
After:
cmd /k ping -n 3 192.168.1.70
There's no need to run cmd from within your batch file. The line can simply be:

ping -n 3 192.168.1.70
 

My Computer My Computer

At a glance

Windows 10/11
OS
Windows 10/11
Computer type
Laptop
Manufacturer/Model
Acer

My Computer My Computer

At a glance

Windows 11 Pro; 21H2, Build 22000.1281AMD Ryzen 3 3250 with Radeon Graphics8gbAMD Graphics
OS
Windows 11 Pro; 21H2, Build 22000.1281
Computer type
Laptop
Manufacturer/Model
Dell 3525
CPU
AMD Ryzen 3 3250 with Radeon Graphics
Memory
8gb
Graphics Card(s)
AMD Graphics
Sound Card
AMD high definition audio device; Realtek audio
Screen Resolution
1980x1020
"Finally"?????
The second window appears in response to the Start command. I don't know what your objective is so I don't know why you did that. The script could otherwise just be
ping -n 10 192.168.1.70
Pause
or
ping -n 10 192.168.1.70


What is your overall objective, what job is the pinging part of?


Denis
 
Last edited:

My Computer My Computer

At a glance

Windows 11 Home x64 Version 25H2 Build 26200....
OS
Windows 11 Home x64 Version 25H2 Build 26200.8037
"Finally"?????



What is your overall objective, what job is the pinging part of?


Denis
Finally means that a single command window opening.

My printer is in another room and has a tendency drop offline so I always check before trying to print.
 

My Computer My Computer

At a glance

Windows 11 Pro; 21H2, Build 22000.1281AMD Ryzen 3 3250 with Radeon Graphics8gbAMD Graphics
OS
Windows 11 Pro; 21H2, Build 22000.1281
Computer type
Laptop
Manufacturer/Model
Dell 3525
CPU
AMD Ryzen 3 3250 with Radeon Graphics
Memory
8gb
Graphics Card(s)
AMD Graphics
Sound Card
AMD high definition audio device; Realtek audio
Screen Resolution
1980x1020

Latest Support Threads

Back
Top Bottom