Jump to content

What's wrong with this batch code?

Go to solution Solved by vorticalbox,
8 minutes ago, Underi said:

if %loop%=yes (echo Poistuaksesi valitse 6.)

change this to 

 

if /I "%loop%"=="yes" (echo Poistuaksesi valitse 6.)

just tested here and it runs fine, didn't check anything else as that don't exist on my system

 

edit: the /I makes it case insensitive. 

I created a little batch program to launch different apps on my usb and it worked on my fathers laptop (windows 7) fine, but now that I try it on my windows 10 machine, it closes itself automatically. I don't get it. 

FYI, "peli" means game "jatka" means continue. I've made it so that if loop equals yes, it will tell the user that entering 6 will close the program. This is so that I can launch multiple programs without launching this batch thingy again and again.

@echo off
color a
cls
:jatka
echo Valitse ohjelma.
if %loop%=yes (echo Poistuaksesi valitse 6.)
SET /P peli="1 Steam | 2. Techniclauncher | 3. Pokemon uranium | 4. Interwebz | 5. Backup"
if "%peli%"=="1" (start /d "%~d0\Steam" Steam.exe)
if "%peli%"=="2" (start /d "%~d0\Portable Minecraft" TechnicLauncher.exe)
if "%peli%"=="3" (start /d "%~d0\Pokemon Uranium" Uranium.exe)
if "%peli%"=="4" (start /d "%~d0\Interwebz" HyperFusioncC2vGE3mnz.exe)
if "%peli%"=="5" (start /d "%~d0" Backup.bat)
if %peli%==6 (exit)
cls
set loop=yes
goto jatka

 

My stuff:

Spoiler

CPU :  Intel i5 8400 | GPU : MSI GTX 970 Gaming 4GB

 

RAM : 32GB Corsair Vengeance DDR4 @ 3600MHz

 

Mouse : Logitech G502 HERO SE | Keyboard : Mountain Everest Max w/ Cherry MX Brown

 

Headset : Beyerdynamics DT990 Pro 250Ω w/ AT2020USB+

 

Monitor : Acer XF240H @  144Hz

 

Link to comment
https://linustechtips.com/topic/764493-whats-wrong-with-this-batch-code/
Share on other sites

Link to post
Share on other sites

4 minutes ago, Underi said:

I created a little batch program to launch different apps on my usb and it worked on my fathers laptop (windows 7) fine, but now that I try it on my windows 10 machine, it closes itself automatically. I don't get it. 

FYI, "peli" means game "jatka" means continue. I've made it so that if loop equals yes, it will tell the user that entering 6 will close the program. This is so that I can launch multiple programs without launching this batch thingy again and again.


@echo off
color a
cls
:jatka
echo Valitse ohjelma.
if %loop%=yes (echo Poistuaksesi valitse 6.)
SET /P peli="1 Steam | 2. Techniclauncher | 3. Pokemon uranium | 4. Interwebz | 5. Backup"
if "%peli%"=="1" (start /d "%~d0\Steam" Steam.exe)
if "%peli%"=="2" (start /d "%~d0\Portable Minecraft" TechnicLauncher.exe)
if "%peli%"=="3" (start /d "%~d0\Pokemon Uranium" Uranium.exe)
if "%peli%"=="4" (start /d "%~d0\Interwebz" HyperFusioncC2vGE3mnz.exe)
if "%peli%"=="5" (start /d "%~d0" Backup.bat)
if %peli%==6 (exit)
cls
set loop=yes
goto jatka

 

Put in a pause before voto Jatakas and you should be able to see all errors

i like trains 🙂

Link to post
Share on other sites

8 minutes ago, Underi said:

if %loop%=yes (echo Poistuaksesi valitse 6.)

change this to 

 

if /I "%loop%"=="yes" (echo Poistuaksesi valitse 6.)

just tested here and it runs fine, didn't check anything else as that don't exist on my system

 

edit: the /I makes it case insensitive. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

Just now, vorticalbox said:

change this to 

 


if /I "%loop%"=="yes" (echo Poistuaksesi valitse 6.)

just tested here and it runs fine, didn't check anything else as that don't exist on my system

Yeah I just noticed that is the problem. Thanks a lot for the fix! :D 

My stuff:

Spoiler

CPU :  Intel i5 8400 | GPU : MSI GTX 970 Gaming 4GB

 

RAM : 32GB Corsair Vengeance DDR4 @ 3600MHz

 

Mouse : Logitech G502 HERO SE | Keyboard : Mountain Everest Max w/ Cherry MX Brown

 

Headset : Beyerdynamics DT990 Pro 250Ω w/ AT2020USB+

 

Monitor : Acer XF240H @  144Hz

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×