AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题 / 76947832
Accepted
Legitz
Legitz
Asked: 2023-08-22 02:19:14 +0800 CST2023-08-22 02:19:14 +0800 CST 2023-08-22 02:19:14 +0800 CST

我的批处理代码在尝试转到 :apps 标签后崩溃

  • 772

我正在为我的朋友编程一些东西,但我的批处理代码不断崩溃。

有人可以帮忙吗?

这是代码:

@echo off
title xinsOS - Boot
echo.
goto load

:load
cls
if exist colour.txt (
    goto loadColour
) else (
    color 7
    goto desktop
)

:loadColour
cls
< colour.txt (
    set /p colour=
)
color %colour%
goto desktop

::Oh, you checked the code...
::while your here i could say this is just an hobby
::it will never be an bootable OS

:desktop
cd "%userprofile%\Documents\xinsOS"
cls
title Desktop
echo                                        Desktop
echo.
echo ([1]) Apps
echo ([2]) Info about the CREATOR
echo ([3]) SystemInfo
echo ([4]) Shutdown and Reboot
choice /N /C:1234
if errorlevel 255 goto desktop
if errorlevel 4 goto shutdown
if errorlevel 3 goto sysInfo
if errorlevel 2 goto CREATORinfo
if errorlevel 1 goto apps
if errorlevel 0 goto desktop

:sysInfo
cls
title System info
echo                                        System Info
echo.
echo.
echo Operating system: xinsOS v0.2
echo RAM: 16MB
echo CPU: XINS-I
echo Computer name: XINS-PC-001
echo PC-SERIAL-NUMBER: 0101-1011-1101-1010
pause>nul
goto desktop                

:apps
cd DownloadedApps
if exist "xinsPad\xinsPad.bat" (
    cls
    title Apps - xinsOS
    echo.
    echo                                        Apps
    echo.
    echo ([1]) xinsSettings
    echo ([2]) xinsPad
    echo ([3]) App Store
    echo ([4]) Back
    choice /N /C:1234
    if errorlevel 255 goto apps
    if errorlevel 4 goto desktop
    if errorlevel 3 goto StartXinsPad
    if errorlevel 2 goto appstore
    if errorlevel 1 goto xinssettings
    if errorlevel 0 goto apps
) else (
    echo hi
)

:xinssettings
cls
title Settings - xinsOS
echo.
echo.
echo ([1]) Colors
echo ([2]) Language
echo ([3]) Back
choice /N /C:123
if errorlevel 255 goto xinssettings
if errorlevel 3 goto apps
if errorlevel 2 goto language
if errorlevel 1 goto colors
if errorlevel 0 goto xinssettings

:colors
cls
title Choose colour - xinsOS
echo.
echo.
echo.
echo.
echo Choose Colour:
echo.
echo.
echo ([1]) Red
echo ([2]) Blue
echo ([3]) Matrix style
echo ([4]) Purple
echo ([5]) Aqua
echo ([6]) Back
choice /N /C:123456
if errorlevel 255 goto colors
if errorlevel 6 goto xinssettings
if errorlevel 5 goto SaveAqua
if errorlevel 4 goto SavePurple
if errorlevel 3 goto SaveGreen
if errorlevel 2 goto SaveBlue
if errorlevel 1 goto SaveRed
if errorlevel 0 goto colors

:SaveRed
color 4
echo Saving color settings...
set colour=4
(
    echo %colour%
)>colour.txt
goto colors

:SaveBlue
color 1
echo Saving color settings...
set colour=1
(
    echo %colour%
)>colour.txt
goto colors

:SaveGreen
color 2
echo Saving color settings...
set colour=2
(
    echo %colour%
)>colour.txt
goto colors

:SavePurple
color 5
echo Saving color settings...
set colour=5
(
    echo %colour%
)>colour.txt
goto colors

:SaveAqua
color 3
echo Saving color settings...
set colour=3
(
    echo %colour%
)>colour.txt
goto colors

:language
cls
title Language Settings - xinsOS
echo.
echo.
echo ([1]) English (currently chosen)
echo ([2]) Deutsch/German

:appstore
cls
title App Store - xinsOS
echo.
echo                                        App Store
echo.
echo ([1]) xinsPad 
echo ([2]) Back
choice /N /C:12
if errorlevel 255 goto appstore
if errorlevel 2 goto apps
if errorlevel 1 goto downloadxinspad
if errorlevel 0 goto appstore

:downloadxinspad
cls
title Downloading xinsPad - xinsOS
echo.
echo                                        xinsPad Download
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Starting Download
timeout /t 2 /nobreak > nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Starting Download.
timeout /t 2 /nobreak > nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Starting Download..
timeout /t 2 /nobreak > nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Starting Download...
timeout /t 4 /nobreak > nul
cls
echo Starting Download    - 0KB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading.   - 400KB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading..  - 600KB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading... - 800KB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading    - 1.2MB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading.   - 1.6MB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading..  - 2.0MB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading... - 2.4MB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading    - 2.8MB/s
timeout /t 1 /nobreak > nul
cd "%userprofile%\Documents\xinsOS\DownloadedApps"
mkdir xinsPad
xcopy "%userprofile%\Documents\xinsOS\Dependencies\xinsPad" "%userprofile%\Documents\xinsOS\DownloadedApps\xinsPad" > nul
cls
echo Downloading.   - 3.2MB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading..  - 3.6MB/s
timeout /t 1 /nobreak > nul
cls
echo Downloading... - 4.0MB/s
timeout /t 5 /nobreak > nul
cls
echo Finished!
timeout /t 3 /nobreak > nul
goto appstore

:CREATORinfo
cls
title INFO ABOUT THE CREATOR - XINSOS
echo.
echo                 INFO ABOUT THE CREATOR
echo.
echo xinsOS was made by a 10 year old, now 11 year old. (No really, it was). His name is Max Atkinson. He is from Germany.
echo He was born in February 16th 2012, in Germany.
echo He first started programming at 6 years old, just right after getting his first laptop, which 4 years later, he is still programming on.
echo He saw a video from IProgramInCPP, who made his own "OS" in Batch.
echo That was his inspiration to create his own. He first made maxOS, which was discontinued 2 days after initial release.
echo  No download is available.
echo Then he made BeeOS, which was discontinued 1 week after initial release.
echo No download available.
echo His video which he made which was called: "Check if Updates are available. | BeeOS", was very cringe.
echo His video didn't make any sense. Here is his youtube channel:
echo https://www.youtube.com/@beeos2639
echo Then he made choOS, which was discontinued 2 weeks after initial release.
echo He just didn't have any motivation anymore.
echo But 1 year later, HE IS BACK!
echo.
echo With xinsOS!
echo He himself said: "I do not have any dates where xinsOS will be discontinued. But I hope you guys enjoy this "OS" made by me!"
echo That was the end of info about the CREATOR. We all at the xinsOS Team, wish you a rest of the day/night.
echo And enjoy the "OS"!
echo PS: this is just a hobby, Max doesn't ever plan to make this a bootable and famous OS. But you never know, maybe he will!
echo Press 1 to see the credits.
echo ([1]) Credits
echo ([2]) Back
choice /N /C:12
if errorlevel 255 goto CREATORinfo
if errorlevel 2 goto desktop
if errorlevel 1 goto credits
if errorlevel 0 goto CREATORinfo

:credits
cls
title CREDITS - xinsOS
echo.
echo.
timeout /t 3 /nobreak > nul
cls
echo CREDITS
echo.
echo.
echo.
timeout /t 3 /nobreak > nul
cls
echo.
echo.
echo.
echo MAX ATKINSON - Creator of the OS.
timeout /t 3 /nobreak > nul
cls
echo.
echo.
echo.
echo KAEJ KAM - Creator of the credits.
timeout /t 3 /nobreak > nul
cls
echo.
echo.
echo.
echo Compo and Stephan (from StackOverflow) - helping me with the code
echo.
echo.
echo.
echo THE END OF CREDITS
timeout /t 3 /nobreak > nul
echo.
echo.
echo.
echo.
echo.
echo.
cls
goto CREATORinfo

:shutdown
cls
title WDYWTD - xinsOS
echo What do you want to do?
echo.
echo ([1]) shutdown
echo ([2]) reboot
echo ([3]) back
choice /N /C:123
if errorlevel 255 goto shutdown
if errorlevel 3 goto desktop
if errorlevel 2 goto reboot
if errorlevel 1 exit
if errorlevel 0 goto shutdown

:reboot
cls
title reboot
echo.
echo.
echo rebooting.
timeout /t 1 /nobreak > nul
cls
echo rebooting..
timeout /t 1 /nobreak > nul
cls
echo rebooting...
timeout /t 1 /nobreak > nul
cls
goto "%userprofile%\Documents\xinsOS"
start desktop.cmd
exit
pause>nul

我尝试转到标签:apps,但我的代码不断崩溃,我不知道为什么。

batch-file
  • 1 1 个回答
  • 22 Views

1 个回答

  • Voted
  1. Best Answer
    SomethingDark
    2023-08-22T02:31:04+08:002023-08-22T02:31:04+08:00

    in被认为)是语句([1])的结尾if,因此它尝试xinsSettings作为命令运行,从而导致错误xinsSettings was unexpected at this time.

    解决这个问题的简单方法是,当您在括号内时,永远不要尝试显示括号,但您也可以在文本编辑器中打开查找和替换,并将所有实例替换为以转义并告诉])解释]^)器)不要将其视为常规括号。

    echo ([1]^) xinsSettings
    echo ([2]^) xinsPad
    echo ([3]^) App Store
    echo ([4]^) Back
    

    ETC。

    • 0

相关问题

  • 批处理文件删除变量中.#后面的文本

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    使用 <font color="#xxx"> 突出显示 html 中的代码

    • 2 个回答
  • Marko Smith

    为什么在传递 {} 时重载解析更喜欢 std::nullptr_t 而不是类?

    • 1 个回答
  • Marko Smith

    您可以使用花括号初始化列表作为(默认)模板参数吗?

    • 2 个回答
  • Marko Smith

    为什么列表推导式在内部创建一个函数?

    • 1 个回答
  • Marko Smith

    我正在尝试仅使用海龟随机和数学模块来制作吃豆人游戏

    • 1 个回答
  • Marko Smith

    java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.http.ClientConfig.<init>(java.net.URI, java.time.Duration, java.time.Duratio

    • 3 个回答
  • Marko Smith

    为什么 'char -> int' 是提升,而 'char -> Short' 是转换(但不是提升)?

    • 4 个回答
  • Marko Smith

    为什么库中不调用全局变量的构造函数?

    • 1 个回答
  • Marko Smith

    std::common_reference_with 在元组上的行为不一致。哪个是对的?

    • 1 个回答
  • Marko Smith

    C++17 中 std::byte 只能按位运算?

    • 1 个回答
  • Martin Hope
    fbrereto 为什么在传递 {} 时重载解析更喜欢 std::nullptr_t 而不是类? 2023-12-21 00:31:04 +0800 CST
  • Martin Hope
    比尔盖子 您可以使用花括号初始化列表作为(默认)模板参数吗? 2023-12-17 10:02:06 +0800 CST
  • Martin Hope
    Amir reza Riahi 为什么列表推导式在内部创建一个函数? 2023-11-16 20:53:19 +0800 CST
  • Martin Hope
    Michael A fmt 格式 %H:%M:%S 不带小数 2023-11-11 01:13:05 +0800 CST
  • Martin Hope
    God I Hate Python C++20 的 std::views::filter 未正确过滤视图 2023-08-27 18:40:35 +0800 CST
  • Martin Hope
    LiDa Cute 为什么 'char -> int' 是提升,而 'char -> Short' 是转换(但不是提升)? 2023-08-24 20:46:59 +0800 CST
  • Martin Hope
    jabaa 为什么库中不调用全局变量的构造函数? 2023-08-18 07:15:20 +0800 CST
  • Martin Hope
    Panagiotis Syskakis std::common_reference_with 在元组上的行为不一致。哪个是对的? 2023-08-17 21:24:06 +0800 CST
  • Martin Hope
    Alex Guteniev 为什么编译器在这里错过矢量化? 2023-08-17 18:58:07 +0800 CST
  • Martin Hope
    wimalopaan C++17 中 std::byte 只能按位运算? 2023-08-17 17:13:58 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve