how to make bat and txt file
Moderator: DosItHelp
how to make bat and txt file
Hi, I have a problem in advance, thank you for your help
I have a bat file and in it:
START wosb /run /systray tm="+5:00:00"
I would like the hour "+5: 00: 00" to add from the txt configuration file that if I enter 4:00:00 or 4 in the txt file, it will change in the batch file?
I have a bat file and in it:
START wosb /run /systray tm="+5:00:00"
I would like the hour "+5: 00: 00" to add from the txt configuration file that if I enter 4:00:00 or 4 in the txt file, it will change in the batch file?
Re: how to make bat and txt file
Could you tell about the structure of your configuration file? Does it only consist of a single line containing 4:00:00?
Steffen
Steffen
Re: how to make bat and txt file
sorry the configuring file is config.ini and not txt if you can do ini config then please help me in it there are
[DelayWakeUp]
Time = 6000
and here I would like to download an hour from here
TimeUP = 5:00:00
if you can't z ini then how to do with a txt file, nothing will be found in it, and ini there are a few other lines below if you need to send everything
[DelayWakeUp]
Time = 6000
and here I would like to download an hour from here
TimeUP = 5:00:00
if you can't z ini then how to do with a txt file, nothing will be found in it, and ini there are a few other lines below if you need to send everything
Re: how to make bat and txt file
This is certainly not foolproof. However I guess it should do the job.
Remove the ECHO and PAUSE commands if it outputs the right START command.
Steffen
Code: Select all
@echo off &setlocal
set "inifile=config.ini"
set "section=DelayWakeUp"
set "key=TimeUP"
setlocal EnableDelayedExpansion
set "inSection="
<"!inifile!" (
for /f %%i in ('type "!inifile!"^|find /c /v ""') do for /l %%j in (1 1 %%i) do (
set "line=" &set /p "line="
if defined line (
if /i "!line!"=="[!section!]" (
set "inSection=1"
) else if defined inSection (
if /i "!line:%key%=!" neq "!line!" (
set "inSection="
set "found=!line!"
)
)
)
)
)
for /f "tokens=1* delims==" %%g in ("!found!") do (
for /f "tokens=1-3 delims=: " %%i in ("%%h") do (
if "%%i"=="" (set "h=0") else set "h=%%i"
if "%%j"=="" (set "m=00") else set "m=%%j"
if "%%k"=="" (set "s=00") else set "s=%%k"
)
)
set "tm=+%h%:%m%:%s%"
ECHO start wosb /run /systray tm="!tm!"
PAUSE
Steffen
Re: how to make bat and txt file
SET YES
[DelayWakeUp]
Time = 60000
TimeUp = 5:00:00
the program starts but does not set the time; / am I doing something wrong?
[DelayWakeUp]
Time = 60000
TimeUp = 5:00:00
the program starts but does not set the time; / am I doing something wrong?
Re: how to make bat and txt file
Code: Select all
&setlocal
set "inifile=config.ini"
set "section=DelayWakeUp"
set "key=TimeUP"
setlocal EnableDelayedExpansion
set "inSection="
<"!inifile!" (
for /f %%i in ('type "!inifile!"^|find /c /v ""') do for /l %%j in (1 1 %%i) do (
set "line=" &set /p "line="
if defined line (
if /i "!line!"=="[!section!]" (
set "inSection=1"
) else if defined inSection (
if /i "!line:%key%=!" neq "!line!" (
set "inSection="
set "found=!line!"
)
)
)
)
)
for /f "tokens=1* delims==" %%g in ("!found!") do (
for /f "tokens=1-3 delims=: " %%i in ("%%h") do (
if "%%i"=="" (set "h=0") else set "h=%%i"
if "%%j"=="" (set "m=00") else set "m=%%j"
if "%%k"=="" (set "s=00") else set "s=%%k"
)
)
set "tm=+%h%:%m%:%s%"
start wosb /run /systray tm="!tm!"
Re: how to make bat and txt file
Leave the first line
Besides of that, did the original code output the expected START command?
Steffen
Code: Select all
@echo off &setlocal
Steffen
Re: how to make bat and txt file
Config.ini
[DelayWakeUp]
Time = 60000
TimeUp = 05:00:00
starts the program but does not enter the time
as I have typed the same:
START wosb /run /systray tm="+5:00:00"
the program starts and time adds up and your bat starts but doesn't add time; /
[DelayWakeUp]
Time = 60000
TimeUp = 05:00:00
Code: Select all
@echo off &setlocal
set "inifile=config.ini"
set "section=DelayWakeUp"
set "key=TimeUP"
setlocal EnableDelayedExpansion
set "inSection="
<"!inifile!" (
for /f %%i in ('type "!inifile!"^|find /c /v ""') do for /l %%j in (1 1 %%i) do (
set "line=" &set /p "line="
if defined line (
if /i "!line!"=="[!section!]" (
set "inSection=1"
) else if defined inSection (
if /i "!line:%key%=!" neq "!line!" (
set "inSection="
set "found=!line!"
)
)
)
)
)
for /f "tokens=1* delims==" %%g in ("!found!") do (
for /f "tokens=1-3 delims=: " %%i in ("%%h") do (
if "%%i"=="" (set "h=0") else set "h=%%i"
if "%%j"=="" (set "m=00") else set "m=%%j"
if "%%k"=="" (set "s=00") else set "s=%%k"
)
)
set "tm=+%h%:%m%:%s%"
start wosb /run /systray tm="!tm!"
as I have typed the same:
START wosb /run /systray tm="+5:00:00"
the program starts and time adds up and your bat starts but doesn't add time; /
Re: how to make bat and txt file
I've been asking about my original code (with ECHO and PAUSE still in). Does it output the expected START command with the "tm=..." set correctly?
The reason why I added those commands is to enable you to check this upfront.
Steffen
The reason why I added those commands is to enable you to check this upfront.
Steffen
Re: how to make bat and txt file
start wosb /run /systray tm="+::"
Press any key to continue . . .
I click the key and nothing happens, the program does not turn on
Press any key to continue . . .
I click the key and nothing happens, the program does not turn on
Re: how to make bat and txt file
if I remove the echo before start, the program starts and the cmd window is started
Re: how to make bat and txt file
In this case the batch code doesn't read the value out of the ini file for a reason that I don't know. Is the ini file in the same directory as the batch file? Is there maybe a space behind the [DelayWakeUp] in the ini file? Difficult for me to tell without having the original file available.
Steffen
Steffen
Re: how to make bat and txt file
hen ... it works you were right I had a space for [DelayWakeUp], thank you very much for your help
Re: how to make bat and txt file
Making the section detection a little more robust (in terms of additional spaces), but also more weak.
Steffen
Code: Select all
@echo off &setlocal
set "inifile=config.ini"
set "section=DelayWakeUp"
set "key=TimeUP"
setlocal EnableDelayedExpansion
set "inSection="
<"!inifile!" (
for /f %%i in ('type "!inifile!"^|find /c /v ""') do for /l %%j in (1 1 %%i) do (
set "line=" &set /p "line="
if defined line (
if /i "!line:[%section%]=!" neq "!line!" (
set "inSection=1"
) else if defined inSection (
if /i "!line:%key%=!" neq "!line!" (
set "inSection="
set "found=!line!"
)
)
)
)
)
for /f "tokens=1* delims==" %%g in ("!found!") do (
for /f "tokens=1-3 delims=: " %%i in ("%%h") do (
if "%%i"=="" (set "h=0") else set "h=%%i"
if "%%j"=="" (set "m=00") else set "m=%%j"
if "%%k"=="" (set "s=00") else set "s=%%k"
)
)
set "tm=+%h%:%m%:%s%"
ECHO start wosb /run /systray tm="!tm!"
PAUSE
Re: how to make bat and txt file
Ok, thanks later, I will check out a big thank you for your helpaGerman wrote: ↑30 Apr 2022 06:03Making the section detection a little more robust (in terms of additional spaces), but also more weak.SteffenCode: Select all
@echo off &setlocal set "inifile=config.ini" set "section=DelayWakeUp" set "key=TimeUP" setlocal EnableDelayedExpansion set "inSection=" <"!inifile!" ( for /f %%i in ('type "!inifile!"^|find /c /v ""') do for /l %%j in (1 1 %%i) do ( set "line=" &set /p "line=" if defined line ( if /i "!line:[%section%]=!" neq "!line!" ( set "inSection=1" ) else if defined inSection ( if /i "!line:%key%=!" neq "!line!" ( set "inSection=" set "found=!line!" ) ) ) ) ) for /f "tokens=1* delims==" %%g in ("!found!") do ( for /f "tokens=1-3 delims=: " %%i in ("%%h") do ( if "%%i"=="" (set "h=0") else set "h=%%i" if "%%j"=="" (set "m=00") else set "m=%%j" if "%%k"=="" (set "s=00") else set "s=%%k" ) ) set "tm=+%h%:%m%:%s%" ECHO start wosb /run /systray tm="!tm!" PAUSE