-3

I started to create a text based adventure game named TeaBAG. It works in Windows 10 (if I change all the 11s in lines 3-4 to 10), but it doesn't seem to work in Windows 11. I know that the administrator part isn't required, but I want it in the code in case I add more to it. I tried changing multiple parts, but it doesn't work. The .bat file doesn't even start, so I can't debug by adding "pause" to the end. Is there any way to fix this, or do I have to remake the entire thing in Python (I plan to do this anyways, but I want a working batch version)?

Part of the code:

@echo off
color 04
wmic OS get OSArchitecture,caption | FIND "11" >nul || ECHO Please use Windows 11 English && TIMEOUT 5 >nul && EXIT
echo Windows 11 Detected!
color 0f
cd %SystemRoot%\system32
Reg query "HKU\S-1-5-19\Environment"
if '%errorlevel%' NEQ '0' (
    goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"="
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    taskkill /f /IM explorer.exe
    start explorer.exe
    cls
    color 04
    echo Enable ADMIN to play this game!
    pause
    exit /b
:gotAdmin
    cd %homepath%
color 0f
set key=no
set unlocked=no
set color=0f
cls
Reg query "HKU\S-1-5-19\Environment"
if '%errorlevel%' NEQ '0' (
    color 04
    echo Enable ADMIN to play this game!
    pause
    exit /b
) else ( goto :options )
:options
set /p input="Settings: Color (Light/Dark/Custom)> "
echo %input%|find /i "light" >nul && (echo Set color type to light! & goto :optionlight)
echo %input%|find /i "dark" >nul && (echo Set color type to dark! & goto :optiondark)
echo %input%|find /i "custom" >nul && (echo Choose your color. & goto :optioncustom)
goto :options
:optionlight
color f2
set color=f2
goto :loopstart
:optiondark
color 0a
set color=0a
goto :loopstart
:optioncustom
echo: Color attributes are specified by TWO hex digits -- the first
echo: corresponds to the background; the second the foreground.  Each digit
echo: can be any of the following values:

echo:    0 = Black       8 = Gray
echo:    1 = Blue        9 = Light Blue
echo:    2 = Green       A = Light Green
echo:    3 = Aqua        B = Light Aqua
echo:    4 = Red         C = Light Red
echo:    5 = Purple      D = Light Purple
echo:    6 = Yellow      E = Light Yellow
echo:    7 = White       F = Bright White

echo: If you do not put a valid input, a error message will pop up and the color will set to 0F
set /p input="Settings: Color (Custom)> "
echo %input% >nul && (echo Set color type to %input%! & goto :finishsettings)
goto :optioncustom
:finishsettings
set color=%input%
color %color%
goto :loopstart
:loopstart
set /p input="Type Start to start> "
echo %input%|find /i "start" >nul && (echo Ok, started The Batch Adventure Game! & goto :next)
goto :loopstart
:next
echo ...
echo You wake up in a house, in the middle of a forest.
echo You get up and decide to explore the area.
echo One of the trees looks strange. You may want to climb it.
echo You also see a path leading away from the house you woke up in.
echo The house is also probably yours. Let's not touch anything in it just to be sure though.
echo ...
:YourHouse
echo Location: Your House
echo What do you do?
echo Type OPTIONS to show available options!
:YourHouseLoop
set /p input="Your House> "
echo %input%|find /i "Climb Tree" >nul && (echo You climb the tree. & goto :TreeTop)
echo %input%|find /i "OPTIONS" >nul && echo Climb Tree, Explore Path, Unlock Tree (Requires KEY)
echo %input%|find /i "Explore Path" >nul && (echo You wander to the path... & goto :HousePath)
echo %input%|find /i "Unlock Tree" >nul && (echo You attempt to unlock the tree. & goto :TreeTopUnlock)
REM choose your keywords wisely...
goto :YourHouseLoop
:TreeTop
if %unlocked%==yes (goto :aether) else (goto :TreeTopNothing)
echo You go into the Aether.
:aetherunlocked
echo A click rings around the house. A portal appears.
goto :YourHouse
:TreeTopNothing
echo There's nothing there. Maybe go check out the path?
echo You climb back down the tree.
goto :YourHouse
:HousePath
echo Location: Shtua
echo The path leads to a small village.
echo You see a person waving at you!
echo What do you do?
echo Type OPTIONS to show available options!
:VillageLoopOverworld
set /p input="Village> "
echo %input%|find /i "Talk to Waving Villager" >nul && (echo You talk to the villager. & goto :TalkOverworldVillager)
echo %input%|find /i "Options" >nul && echo Talk to Waving Villager, Back
echo %input%|find /i "Back" >nul && (echo You go back to your house. & goto :YourHouse)
goto :VillageLoopOverworld
:TalkOverworldVillager
echo You: Hey. Why were you waving at me?
timeout 1 >nul
echo Villager: You seemed lost. Did you come from the other world?
timeout 1 >nul
echo You: Yeah I'm lost. But what other world are you talking about?
timeout 1 >nul
echo Villager: You don't know about the other world?
timeout 1 >nul
echo Villager: Come into my house. You probably did come from the other world.
timeout 1 >nul
echo You: But... WAIT. What's your name?
timeout 1 >nul
echo Villager: Robert. Now come in.
timeout 1 >nul
echo You enter the house.
goto :overworldhouse
:overworldhouse
echo: Location: Shtua Village House
echo: Robert: Let me guess. You have no memory about anything, right?
timeout 1 >nul
echo: You: Yeah.
timeout 1 >nul
echo: Robert: Ok, well, here's a book for you to read. It contains all the information about the other world, known as the Aether, to the current date. Read it, then I'll explain. It also includes a key to the Aether world, if you find the location to unlock it!
echo: You received 1 Book: "Aether Guide"
goto :readbookaetherguide
:readbookaetherguide
echo: You received 1 Key: "Aether Key"
set key=yes
Pause
echo When Earth formed, something strange happened. The Gods, who create all worlds and dimensions, created Earth as a 
echo: no magic place. Because only people with incredibly powerful magic can open portals to other worlds in
echo: different dimensions, it was essentially impossible for the species of Earth to go to different worlds.
echo: Aether is one of these worlds. Fifteen billion years in the past, and the first world formed by the gods, it had
echo: incredibly powerful magic. Many species lived there in peace. To get there from Earth, it would require enough magic
echo: to go through three dimensions, and time travel fifteen billion years into the past. So the species of Earth
echo: had no access to the origin of magic, Aether. But during the creation of the world, multiple worlds connected to Aether was
echo: destroyed. This sent powerful blasts of magic throughout dimensions, time traveling, warping, and finally one of those
echo: blasts landed on Earth. The gods were aware of this, but because of the blasts power, the gods couldn't do anything at
echo: all. They finished creating Earth, and abandoned it. A few billion years later, humans started to
echo: become more and more intelligent. At the same time, the magic that landed on Earth, started to mutate. Because it
echo: Page 1. 1/2.
pause
Echo: was from the Aether, it mutated into a permanent portal connection to the Aether before stabilizing. Permanent portals to the
Echo: Aether are incredibly rare, and all of them are forceibly shut down by the Aether Council, the leaders of Aether.
Echo: However, this permanent portal was so powerful, the Aether Council couldn't shut it down. So they locked it up.
Echo: Thousands of years later, humanity has just sent mankind to the moon. Meanwhile, the portal was forgotten in a remote
Echo: location, and not much people knew about it. Only the village next to it knew. This village, the guardians of the portal,
Echo: has guarded this place since the beginning. So when sounds of magic and war started coming through the portal,
Echo: they knew something was going on. So, someone was sent to explore. What they found, was chaos. The entire Aether
Echo: had gone to absolute war. An evil primordial deity had taken over the Aether Council. Only one person
Echo: could take down the primordial deity Chaos. The gods couldn't stop Chaos, mostly because primordial deities were the more
Echo: powerful parents of the gods. The other primordial deities also couldn't stop Chaos, because only one other was free, and
Echo: he wasn't powerful enough. So everything rested on one person, a baby, but a baby that would soon become the most powerful
Echo: entity ever. However, before he finished receiving his powers from the Aether Fountain, the source of all power, he dissapeared.
Echo: Nobody knew where he went. It is now the year 2021, and effect from the Aether War has come through the portal in the
Echo: form of a pandemic...
Echo: Page 2. 2/2.
pause
echo You: I finished, but what does this have to do with me?
timeout 1 >nul
echo Robert: Well, since you don't have your memories, you might be the person who could stop Chaos.
echo Robert: If you don't, everything will die. Aether, Earth, the gods, everything.
echo Robert: There's only one way to stop this. You. We'll need to unlock your memories.
echo Robert: This is difficult as there is only one way to unlock them. To go to the Aether Fountain and unlock the rest of your powers.
echo Robert: You still have some powers to help you on the way. You'll need it!
timeout 5 >nul
echo You: Hang on. You're telling me that I'm the person who can stop Chaos? Are you joking?
timeout 1 >nul
echo Robert: Unfortunately no. Now, use the key to unlock the big tree near that house you probably woke up in. Take the book and key.
timeout 1 >nul
echo You: ... Ok fine.
goto :HousePath


:treetopunlock
if %unlocked%==yes (echo Aether already unlocked!) else (if %key%==yes (goto :aetherunlocked) else (goto :UnlockTreeFail))
:UnlockTreeFail
echo: You don't have the key!
goto :YourHouse
:aetherunlocked
set unlocked=yes
echo Unlocked the Aether!
goto :YourHouse
:aether
cls
color 04
echo: Aether not done.
pause
color %color%
cls
goto :YourHouse
  • 1
    Q: What's the file suffix? ".bat"? Q: Have you tried running in a command prompt window? What (if anything) do you see in the window? – paulsm4 May 27 '22 at 17:07
  • It's a .bat (not .cmd) as mentioned in the question. I haven't tried to run it in a command prompt window yet, I'll do that later. However, it seems to be a syntax error and theres too many lines to run them all efficiently. – YumYummity May 27 '22 at 17:19
  • 1
    Please read [debugging a batch file](https://stackoverflow.com/a/42448601/3074564). If you think, it takes you too much time to change the first line from `@echo off` to `@echo ON` and run the batch file from within a command prompt window to see which lines are executed as expected by you and where the syntax error finally occurs resulting in an exit of batch file processing, then I have to come to the same opinion. It takes too much time for me too. PS: I think, I would change most of the lines after a quick view on the lines. – Mofi May 27 '22 at 17:28
  • 1
    PPS: A batch file game which requires the elevated privileges of a local administrator and Windows 11? __That is a malware batch script in my opinion.__ It forces a kill of all running instances of `explorer.exe` including the Windows Shell. That is definitely a malware script. – Mofi May 27 '22 at 17:33
  • https://i.imgur.com/Y7ikHCH.png Your script works fine in Windows 11, the problem is on your end. – SomethingDark May 27 '22 at 18:33
  • `WMIC.exe` is no longer part of Windows, as of version 11 of the Operating System. – Compo May 27 '22 at 19:19
  • @Compo - [Yes, it is](https://imgur.com/BIgfdcf) – SomethingDark May 27 '22 at 19:26
  • The WMIC command line tool is deprecated and will be removed completely from Windows 11, probably in the next major update. – Anon Coward May 27 '22 at 21:18
  • Just to better explain what I meant, @SomethingDark. The code is specifically identifying only the string `11`. So after the next major update, (standard or fast channel), the script will exit for everything other than early versions on Windows 11, and that I'm sure, is not the intention! – Compo May 27 '22 at 22:00

0 Answers0