-2

How do I save and load with a batch file I wish to save and load variables think you can make that happen?

Vakors 3000
  • 211
  • 1
  • 9
  • 1
    Does this answer your question? [Save and Load .bat game -- Error with single numbers](https://stackoverflow.com/questions/7721978/save-and-load-bat-game-error-with-single-numbers) – T3RR0R Dec 15 '20 at 03:59
  • If all the environment variables to save and load start with same substring which no other environment variable has by default like `MyAppName_`, the saving of the variables can be done with `set MyAppName_>"%APPDATA%\MyAppName.ini"` and loading with `if exist "%APPDATA%\MyAppName.ini" for /F "usebackq delims=" %%I in ("%APPDATA%\MyAppName.ini") do set "%%I"`. That's it. The loading command line works also if the variables do not all start with same substring. – Mofi Dec 15 '20 at 07:46
  • But saving of multiple environment variables not starting all with the same substring requires to output with `echo` one after the other the environment variable name, an equal sign and the current value of the environment variable and the series of `echo` commands is within a command block starting with `(` and ending with `)>"%APPDATA%\MyAppName.ini"`. You have unfortunately not posted anything about the variables to save/load and so it is not possible to post for you a code which is working for the variables used by you in your batch file. – Mofi Dec 15 '20 at 07:54

1 Answers1

0

first set your variable set money=100 now set your name set /p name=name: Lastly, save the variable in save.bat You might be wondering how to save it the answer is here. echo set money=%money% >>save1.cmd and

echo set name=%name% Ok now for load DO THIS IN A DIFFERENT FILE OR THE SAME IF YOU HAVE SET UP A MENU SAVE LOAD SYSTEM Now Call Save1.cmd then

Echo name: %name%

echo money: %money% pause all done

Vakors 3000
  • 211
  • 1
  • 9