Solved I can't run bat and cmd files.


toprak

Member
Local time
4:46 PM
Posts
4
OS
Windows 11
Hello guys, I do not know why, but I just can't run .bat and .cmd files with double click like before. I have to run first Windows Terminal and execute the scripts on that terminal session. When I click right click to bat and cmd files, there are no command line or PowerShell options.
 
Windows Build/Version
Version 23H2 (OS Build 22631.3007)

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ITOPYA TEKNOHAYAT-11
    CPU
    AMD Ryzen 5 5500
    Motherboard
    ASUS PRO B550M-C/CSM
    Memory
    2x Kingston 8GB FURY Beast
    Graphics Card(s)
    ASUS Dual GeForce RTX 3050 OC Edition 8GB
    Monitor(s) Displays
    Lenovo Legion R25i-30
    Screen Resolution
    1920x1080
    Hard Drives
    WD 500GB Blue SN570 Gen3x4 M.2 2280 SSD
    PSU
    GameBooster GB-G3309B 550W 80+
    Case
    GameBooster GB-G3309B
    Cooling
    GameBooster GB-G3309B
    Keyboard
    SteelSeries Apex Pro TKL
    Mouse
    SteelSeries Prime
    Internet Speed
    100mbps
    Browser
    Microsoft Edge
Hello toprak, :alien:

You could test using option two in the tutorial below to reset these file types back to default to see if it may help.

 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360 2in1 14-eu0098nr (2024)
    CPU
    Intel Core Ultra 7 155H 4.8 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Graphics card(s)
    Integrated Intel Arc
    Sound Card
    Poly Studio
    Monitor(s) Displays
    14" 2.8K OLED multitouch
    Screen Resolution
    2880 x 1800
    Hard Drives
    2 TB PCIe NVMe M.2 SSD
    Internet Speed
    Intel Wi-Fi 7 BE200 (2x2) and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender and Malwarebytes Premium
Check that .bat and .cmd entries are listed in response to this command, in a Command prompt window, which lists all parts of the System environment variable called PathExt
echo %PathExt%
Open Command Prompt - TenForumsTutorials
Open Command Prompt - ElevenForumTutorials

A normal response to this command is:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

Faults in the PathExt System environment variable are not common but do get reported from time to time.
If there's a problem, see
List of Environment Variables - TenForumsTutorials
List of Environment Variables - ElevenForumTutorials
Set New User and System Environment Variables - TenForumsTutorials
Path, PathExt - SS64
PathExt is also referred to in Command shell overview - MSDocs and discussed in Order in which command prompt executes files with the same name (a.bat vs a.cmd vs a.exe) - Stack Overflow


All the best,
Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Hello toprak, :alien:

You could test using option two in the tutorial below to reset these file types back to default to see if it may help.

It worked, thanks.
Check that .bat and .cmd entries are listed in response to this command in a Command prompt window
echo %PathExt%
Open Command Prompt - TenForumsTutorials
Open Command Prompt - ElevenForumTutorials

A normal response to this command is:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

Faults in the PathExt System environment variable are not common but do get reported from time to time.
If there's a problem, see
List of Environment Variables - TenForumsTutorials
List of Environment Variables - ElevenForumTutorials
Set New User and System Environment Variables - TenForumsTutorials
Path, PathExt - SS64
PathExt is also referred to in Command shell overview - MSDocs and discussed in Order in which command prompt executes files with the same name (a.bat vs a.cmd vs a.exe) - Stack Overflow


All the best,
Denis
After resetting, it gave the normal responses, thanks.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ITOPYA TEKNOHAYAT-11
    CPU
    AMD Ryzen 5 5500
    Motherboard
    ASUS PRO B550M-C/CSM
    Memory
    2x Kingston 8GB FURY Beast
    Graphics Card(s)
    ASUS Dual GeForce RTX 3050 OC Edition 8GB
    Monitor(s) Displays
    Lenovo Legion R25i-30
    Screen Resolution
    1920x1080
    Hard Drives
    WD 500GB Blue SN570 Gen3x4 M.2 2280 SSD
    PSU
    GameBooster GB-G3309B 550W 80+
    Case
    GameBooster GB-G3309B
    Cooling
    GameBooster GB-G3309B
    Keyboard
    SteelSeries Apex Pro TKL
    Mouse
    SteelSeries Prime
    Internet Speed
    100mbps
    Browser
    Microsoft Edge
Great news. :shawn:
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360 2in1 14-eu0098nr (2024)
    CPU
    Intel Core Ultra 7 155H 4.8 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Graphics card(s)
    Integrated Intel Arc
    Sound Card
    Poly Studio
    Monitor(s) Displays
    14" 2.8K OLED multitouch
    Screen Resolution
    2880 x 1800
    Hard Drives
    2 TB PCIe NVMe M.2 SSD
    Internet Speed
    Intel Wi-Fi 7 BE200 (2x2) and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender and Malwarebytes Premium
Brink,

I could not find an ElevenForumTutorial for Set New User and System Environment Variables - TenForumsTutorials


Happy New Year,
Denis
I'll add it to the list. :alien:

EDIT:

 
Last edited:

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360 2in1 14-eu0098nr (2024)
    CPU
    Intel Core Ultra 7 155H 4.8 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Graphics card(s)
    Integrated Intel Arc
    Sound Card
    Poly Studio
    Monitor(s) Displays
    14" 2.8K OLED multitouch
    Screen Resolution
    2880 x 1800
    Hard Drives
    2 TB PCIe NVMe M.2 SSD
    Internet Speed
    Intel Wi-Fi 7 BE200 (2x2) and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender and Malwarebytes Premium

My Computer

System One

  • 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
Check this and it was the same:
If it was the same then that environment variable is not the cause of your problem.

Also did the bat reset
Which tutorial was that in?

it still opens a terminal window
What exactly is "it"?
A Terminal window not a cmd window?
Terminal shortcut - %LocalAppData%\Microsoft\WindowsApps\wt.exe
Cmd shortcut - cmd.exe



Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
What exactly is "it"?
PingPrinter.bat
Code:
Start ping -n 10 192.168.1.70

Pause
 

My Computer

System One

  • 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
And the window it opens looks like this?
Terminal, Command prompt.png


Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447

My Computer

System One

  • 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
It sounds as though the file association has been corrupted but your Registry entry is correct [it's the same as mine].
Does SFC help? Since the Registry entry is correct, Windows is not obeying it so SFC seems worth checking.

Sorry, got to rush,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
I should also have checked:-
Do all batch files behave like this?


Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
I should also have checked:-
Do all batch files behave like this?


Denis
No...
Ran SFC and it did not find any problems. If I ad a shortcut to the problem .bat and select "Run as administrator" it acts normal.

Finally found what is causing the problem - pause at the end of the .bat, works fine without it. Even with the pause, it closes the running .bat window and leaves the powershell window open.
 
Last edited:

My Computer

System One

  • 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
I ran your batch file and it ran in cmd windows.
rdway script.png

Even with the pause, it closes the running .bat window and leaves the powershell window open
I had no PS window at all.

I did not need Admin approval.
The only difference that Admin permission made was that it all ran in the System32 file The non-Admin run initial window was in the folder that the batch file was saved in.

The only difference that deleting Pause makes is that the initial window completes & closes so fast that it is not seen.
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



Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
When running:
ping -n 10 192.168.1.70
Pause

It should show the results of the command like this:
Screenshot 2024-03-06 105212.png

But it looks like this (used your image):
Terminal, Command prompt.png
 

My Computer

System One

  • 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
It should show the results of the command like this:
I agree.
The response to the ping command [without also using a Start command] would be like that, in a single window.

But it looks like this (used your image):
Please would you post a screenshot of yours so I can look for any clues that it might hold.


Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Just found out something else, I can't do a print screen any more, it opens snipping tool and closes any open drop downs.
Screenshot 2024-03-06 112524.png
 

My Computer

System One

  • 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
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:

1709742822942.png

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

1709743008252.png

The batch file will run the same regardless of the host. It's the same Cmd.exe interpreter either way.
 

My Computer

System One

  • OS
    Windows 10/11
    Computer type
    Laptop
    Manufacturer/Model
    Acer
Back
Top Bottom