Solved Can't open .bat file

can2x

New member
Local time
1:00 AM
Messages
10
Hello! I recently reinstall my laptop with Windows 7 Ultimate 64-bit. I think everything is alright and I didn't find any 'critical' error. After reinstall complete, then I re-install all my software back (like IDM, Google Chrome, Notepad++, Steam, etc). But now I found a problem! I make a .bat file but can't open it. When I double click on it, the cmd window appear and then disappear and nothing happen! I try to make .bat file again but this time, with a simple command. But the cmd still crash. But when I install a RIP game (with the main installation file named "unpack.bat") the cmd show and everything work properly! I hope there are someone there want to help me :cry:

Also, "sorry for my bad english" :D
 

My Computer

Computer type
Laptop
OS
Windows 7 Ultimate 64bit
Double-clicking on a file will cause the default action to be performed for that file. For most files, there is an associated program that will be invoked and the file passed as a parameter to it so the file will be opened in that program. For files like .bat, .exe .com, their default action is to be executed. When you double-click on a .bat file, then the system will run the .bat file which is why you see the command window open and close.

In order to edit a .bat file, you need to right-click on it and select Edit or Open from the menu.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home Built desktop, Dell G15 5511 Gaming laptop,MS Surface Pro 7 tablet
OS
W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
CPU
3.7Ghz 8700K i7, i7-11800H, i7-1065G7
Motherboard
ASUS TUF Z370-Pro Gaming in desktop
Memory
16G desktop, 16G laptop, 4G tablet
Graphics Card(s)
AMD Radeon RX580, RTX 3060, Intel Iris Plus
Sound Card
High Definition Audio (Built-in to mobo)
Monitor(s) Displays
Samsung U32J59 32" (2x), 15.6", 12"
Screen Resolution
3840x2160, 3840x2160, 1920x1080, 2160x1440
Hard Drives
500G SSD for OS; 2T, 10T & 15T HDDs for Data on Desktop, 1TB SSD laptop, 128G SSD tablet.
PSU
Corsair CX 750M
Case
Antec 100
Cooling
CM 212+
Keyboard
IBM Model M - used continuously since 1986
Mouse
Microsoft Pro IntelliMouse
Internet Speed
400M down 8M up
Antivirus
Windows Defender
Browser
FireFox
Other Info
Built my first computer (8Mhz 8088cpu, 640K RAM, 20MB HDD, 2 360K floppy drives) in 1985 and have been building them for myself, relatives and friends ever since.
Hello! I recently reinstall my laptop with Windows 7 Ultimate 64-bit. I think everything is alright and I didn't find any 'critical' error. After reinstall complete, then I re-install all my software back (like IDM, Google Chrome, Notepad++, Steam, etc). But now I found a problem! I make a .bat file but can't open it. When I double click on it, the cmd window appear and then disappear and nothing happen! I try to make .bat file again but this time, with a simple command. But the cmd still crash. But when I install a RIP game (with the main installation file named "unpack.bat") the cmd show and everything work properly! I hope there are someone there want to help me :cry:

Also, "sorry for my bad english" :D

What is the purpose of the .bat file you are creating? Are you trying to execute it or edit it? You can post the file in the forum for analysis, if you want further help.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built
OS
Windows 7 Professional x64
CPU
Intel i5 quad processor
Motherboard
DP67BG
Memory
16 GB
Graphics Card(s)
Radeon HD 5770
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
Samsung SyncMaster
Screen Resolution
1920X1080
Hard Drives
WD 2TB (SATA Internal)
WD 1TB (USB External)
PSU
Corsair GS800
Case
Tower (Generic)
Cooling
3 Internal Fans
Keyboard
MS Wireless
Mouse
MS Optical Wired
Internet Speed
54 mbps
Antivirus
Emsisoft
Browser
IE-Version 9, Palemoon-Version 24.2.0
Also, open a Elevated Command Prompt.
Type echo %pathext% and press Enter.

Result should look like this:

>echo %pathext%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Double-clicking on a file will cause the default action to be performed for that file. For most files, there is an associated program that will be invoked and the file passed as a parameter to it so the file will be opened in that program. For files like .bat, .exe .com, their default action is to be executed. When you double-click on a .bat file, then the system will run the .bat file which is why you see the command window open and close.

In order to edit a .bat file, you need to right-click on it and select Edit or Open from the menu.

My problem is, if I double click the .bat, a cmd window (or something ...) appear and disappear. Um, I mean, it always crash! I didn't choose any other text editting program (like Notepad) as 'default action'
 
Last edited:

My Computer

Computer type
Laptop
OS
Windows 7 Ultimate 64bit
Also, open a Elevated Command Prompt.
Type echo %pathext% and press Enter.

Result should look like this:

>echo %pathext%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

Sorry, but I don't understand what do you mean
 

My Computer

Computer type
Laptop
OS
Windows 7 Ultimate 64bit
Add a pause command as the last command in your bat file.
That will keep the CMD window open until you click on it ...

You need to edit the bat file as strollin explained in post # 2:
In order to edit a .bat file, you need to right-click on it and select Edit or Open from the menu.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
home built
OS
Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
CPU
AMD Athlon II x4 620
Motherboard
Gigabyte GA-MA785G-UD3H
Memory
6GB GSkill DDR2 800
Graphics Card(s)
AMD 4670 GPU + AMD 4200 IGP
Sound Card
on board Realtek ALC889A
Monitor(s) Displays
RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor
Screen Resolution
1680 x 1050
Hard Drives
OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ...
PSU
Corsair 500 W
Case
Rosewill mid tower
Cooling
CM 90mm rifle
Keyboard
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.

Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.

Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
Add a pause command as the last command in your bat file.
That will keep the CMD window open until you click on it ...

You need to edit the bat file as strollin explained in post # 2:
In order to edit a .bat file, you need to right-click on it and select Edit or Open from the menu.

I know how to edit that. I used both Notepad and Notepad++, but the window still crash and won't execute command (even I'm using simple command as a test)
 

My Computer

Computer type
Laptop
OS
Windows 7 Ultimate 64bit
did you add a pause command as the last statement (command) ?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
home built
OS
Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
CPU
AMD Athlon II x4 620
Motherboard
Gigabyte GA-MA785G-UD3H
Memory
6GB GSkill DDR2 800
Graphics Card(s)
AMD 4670 GPU + AMD 4200 IGP
Sound Card
on board Realtek ALC889A
Monitor(s) Displays
RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor
Screen Resolution
1680 x 1050
Hard Drives
OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ...
PSU
Corsair 500 W
Case
Rosewill mid tower
Cooling
CM 90mm rifle
Keyboard
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.

Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.

Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
did you add a pause command as the last statement (command) ?

No, but that time (before I reinstall my PC) i make a .bat (simple command too). But then I watch a youtube video "How to make a Text-based Game" (There, I learn some basic batch code). I try it myself and it work! But now, I doing it again but this time, it fail! I make other batch file, the same crash happen! What should I do?
 

My Computer

Computer type
Laptop
OS
Windows 7 Ultimate 64bit
Add a pause command so the CMD window will stay open and you can see the error message(s) !!!
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
home built
OS
Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
CPU
AMD Athlon II x4 620
Motherboard
Gigabyte GA-MA785G-UD3H
Memory
6GB GSkill DDR2 800
Graphics Card(s)
AMD 4670 GPU + AMD 4200 IGP
Sound Card
on board Realtek ALC889A
Monitor(s) Displays
RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor
Screen Resolution
1680 x 1050
Hard Drives
OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ...
PSU
Corsair 500 W
Case
Rosewill mid tower
Cooling
CM 90mm rifle
Keyboard
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.

Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.

Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
Here is a very simple bat file i just created.
The 1st command is dir - a valid command
The 2nd command is dirt - an invalid command
The 3rd command is pause - so I can see the error
Code:
dir

dirt

pause
Here is a screen print showing the bat file error, because I have the pause command:

BFESP01.PNG
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
home built
OS
Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
CPU
AMD Athlon II x4 620
Motherboard
Gigabyte GA-MA785G-UD3H
Memory
6GB GSkill DDR2 800
Graphics Card(s)
AMD 4670 GPU + AMD 4200 IGP
Sound Card
on board Realtek ALC889A
Monitor(s) Displays
RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor
Screen Resolution
1680 x 1050
Hard Drives
OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ...
PSU
Corsair 500 W
Case
Rosewill mid tower
Cooling
CM 90mm rifle
Keyboard
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.

Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.

Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
Put the pause in as the last line of the batch file as you were asked to do. That will keep the window from closing so you can see what the error is.

As for my question. To open a Elevated Command prompt, click on Start, type cmd. Right click on cmd.exe at the top left of the Start window and select Run as Administrator.

In the Command Prompt window,

Type echo %pathext% and press Enter.

Result should look like this:

>echo %pathext%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Since we don't know hat the .bat file is trying to do, we have no way of knowing how to advise you.

You say the .bat file crashes when you run it because the command window opens then closes. That is the expected result of running a .bat file by double-clicking it unless something in the .bat file prevents that such as a pause prior to the .bat file ending which will prevent the command window from closing and perhaps allow you to see if there have been errors outputted to the command window.

Would it be possible for you to upload the .bat file here so we could see what it is trying to do?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home Built desktop, Dell G15 5511 Gaming laptop,MS Surface Pro 7 tablet
OS
W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
CPU
3.7Ghz 8700K i7, i7-11800H, i7-1065G7
Motherboard
ASUS TUF Z370-Pro Gaming in desktop
Memory
16G desktop, 16G laptop, 4G tablet
Graphics Card(s)
AMD Radeon RX580, RTX 3060, Intel Iris Plus
Sound Card
High Definition Audio (Built-in to mobo)
Monitor(s) Displays
Samsung U32J59 32" (2x), 15.6", 12"
Screen Resolution
3840x2160, 3840x2160, 1920x1080, 2160x1440
Hard Drives
500G SSD for OS; 2T, 10T & 15T HDDs for Data on Desktop, 1TB SSD laptop, 128G SSD tablet.
PSU
Corsair CX 750M
Case
Antec 100
Cooling
CM 212+
Keyboard
IBM Model M - used continuously since 1986
Mouse
Microsoft Pro IntelliMouse
Internet Speed
400M down 8M up
Antivirus
Windows Defender
Browser
FireFox
Other Info
Built my first computer (8Mhz 8088cpu, 640K RAM, 20MB HDD, 2 360K floppy drives) in 1985 and have been building them for myself, relatives and friends ever since.
Sorry to not listen to your advise(s). But, thanks it work! Thank to everyone who is try to 'fix' my problem!
 

My Computer

Computer type
Laptop
OS
Windows 7 Ultimate 64bit
But this is strange, because before I reinstall my Windows, I don't need the pause command
 

My Computer

Computer type
Laptop
OS
Windows 7 Ultimate 64bit
Glad to hear you got it fixed.

The pause command does nothing to fix any problems in the BAT file.

All it does is prevent the CMD window from closing so you can see what the BAT file did, and if there are any errors you can see the error message(s) and make changes to fix them.

If you have errors in a BAT file you can post them here like I did in post #12 and someone should be able to help you.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
home built
OS
Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
CPU
AMD Athlon II x4 620
Motherboard
Gigabyte GA-MA785G-UD3H
Memory
6GB GSkill DDR2 800
Graphics Card(s)
AMD 4670 GPU + AMD 4200 IGP
Sound Card
on board Realtek ALC889A
Monitor(s) Displays
RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor
Screen Resolution
1680 x 1050
Hard Drives
OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ...
PSU
Corsair 500 W
Case
Rosewill mid tower
Cooling
CM 90mm rifle
Keyboard
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.

Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.

Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
Back
Top