With a friend I'm preparing a nice Minecraft server for the winter. The friend does that every year, this year with the difference that I prepare the one with. Since we observed last time that only three out of 12 players managed to install the mods without help, I decided to write a script that would automate that, I got most of it from the internet, but with some people it fails and people often do not have the nerve or motivation to follow my steps to find out what went wrong. That's why I decided to check if I could just use a log function. I've found one, but now I'm no longer asked questions, basically everything that is normally displayed on "echo something", no longer displayed. Would be cool if someone can tell me why.
Everything from line 10 on worked before
I do not know what to vote for…
The redirection of your call into a file, of course, redirects all issues into the log file. This includes your echoes and user queries…
To test a batch
Take the call line away!
Comment out the @echo off
And put the current path on the batch
:: @ echo off
cd / d "% ~ dp0"
… Etc.
start the console and drag your batch to the console window… Enter.
… And you see what happens.
(It is advisable to set the line buffer of the console, for the analysis, to a width> 1000 and height = 9999)
To the obvious mistakes:
Your batch contains too many conditions related to specific versions of programs.
You are querying a special version of the javaruntime, if the user has installed a newer version or if the requested one has been installed in a path defined by the user, the batch will fail.
Details like:
dir / b% userprofile% \ Appdata \ Roaming \ .minecraft \ mods \> "folderlist.txt"
… Inevitably fail if the name defined in% userprofile% contains a space. Therefore, paths should always be in "Gänsefüßchen".
Setting the time variable is tailored to the English data notation in your batch. This is all sorts of things wrong, since the times of% date% and% time% are localized and are read incorrectly in the string split.
I have saved myself analyzing each line in detail.
The batch you created is too special and puts too many demands on existing third party software (I do not use 7zip but WinRar and will not install the first one on a trial basis).
You write yourself, that you have copied the stuff from the Internet… Something is almost always wrong with such extensive scripts.
If people like me do not even feel like analyzing your mistakes in detail, what do you expect from "normal" users.
Batch is a script language that forgives no mistakes. I really know a lot of pitfalls, but occasionally even with me a batch does not work in the desired way… Then finding the mistake is often a sissyphus work.
PS: Now I'm sitting in front of a PC again and have looked at your batch again in detail… And could run away…
a decent time stamp gets you like this:
for / f "skip = 2 tokens = 2 delims =,. +" %% a in ('wmic os get localdatetime / format: csv') do (
set "TimeStamp = %% ~ a
)
echo% TimeStamp%
this works independently of the local time variable and can be easily compared with gtr == lss. (for milliseconds, use delims =, +)
This spares the whole Gefrickel with string assignment, which works only locally.
Files \ forge-1.7.10-10.13.4.1614-1.7.10-installer.jar
Files \ jre-8u201-windows-x64.exe
Files \ wget
Files \ etc.
… Are no paths over which one could call any programs.
Apart from the Prorammen, which you try to reload automatically, the program for download (wget) is not a standard consol command.
Here would honor the https://ss64.com/ps/bits.html attached to Powershell.
Furthermore, it should be remembered that the virus scanner in general scripts of any kind blocking, which try to load things with wgwet-like routines stuff on the computer.
You may find it convenient to perform any automatic downloads, but I find it rude.
Such a procedure is anything but user-friendly, since the user has no control over what you download and what these programs do!
Here are a few tips on how to find a program in batch or determine the highest installed Java version…
rem search 7z.exe on drive c, no matter which path it was installed!
for / f "tokens = *" %% a in ('dir / b / s "c: \ 7z.exe"') do (
set "__7Zip = %% a"
)
if "% __ 7Zip%" == "" (
echo 7zip not found.
echo 7zip not found. >> "% LOGFILE%"
else (
echo "% __ 7Zip%" found.
)
rem you can now call 7zip.exe via the macro variable "% __ 7Zip%" eg:
rem "% __ 7Zip%" x "meinzip.zip" -oc: \ mypath
rem find the highest installed Java version
for / f "tokens = *" %% a in ('dir / b / o: n / a. "% programfiles% \ java \ jre *"') do (
echo %% ~ nxa
set "javaver = %% ~ nxa"
)
rem only mäkeln if version under jre1.8.0_201
if / i "% javaver%" lss "jre1.8.0_201" (
echo Javaversion =% javaver%.
echo No usable Java version found in "% programfiles% \ java \"…
echo Javaversion =% javaver% >> "% LOGFILE%"
)
Thanks for dealing with my script. The script comes in a folder ("installer"), in which a folder of "files" is called, where everything is inside what is called there. Besides, it's very specific because the older version of Minecraft runs with the mods, only on java8. Add to that the 7zip via the console is available (and it's free). I used Wget because I know it best, and after finding it online for Windoof, I decided to use it, so I write: "Files /" (where wget.exe is) "Files \ wget http://IP.IP.IP.IP.IP/WinterRPG2019/msi_conversion.zip" which downloads msi_conversion.zip into the folder with the script ("installer"), then from 7-Zip ("Files / 7-zip.exe") to "% userprofile% \ Appdata \ Roaming \ .minecraft \ resourcepacks \" is extracted. I just copied how to determine if what is there or not there, the rest I have written myself (therefore these errors). But that was not my question, what you wrote with ":: @ echo off ↙ cd / d"% ~ dp0 "and your way of doing it did not work out.
If you want I can send the whole package so you can see it.