I am currently working on a script for personal pc care, involving cleaning, repair, personal optimizations, ect. The problem I am currently presented with would be easy to work around given that I chose not to work with an ini file, but In this specific case I would like to use an ini for keeping the script simple and easy to read/edit.
CleanConfig.ini
Code: Select all
[Lvl1Clean]
Directory,%temp%,all
Script=W7ClearEventLogs.cmd=blank
[Lvl2Clean]
Directory,C:\SomeFolder\Anotherfolder\,*.log
Script=SomeScriptToRun.cmd=blank
Directory,C:\AnotherFolder\Somefolder\,*.txt
[Lvl3Clean]
Script,SomeScript.cmd,blank
Script,AnotherScript.cmd,blank
Script,AnotherScript.cmd,blank
Directory,C:\SomeCache,*.txt
This file is pretty generic as of now and does not contain any real useful anything, it is just for now to get the script working properly in troubleshooting as I am writing.
Start.cmd
Code: Select all
@echo on
:start
cls
echo *******************
echo CMP Cleaner 1.0
echo *******************
echo.
echo [1] For Level 1 Clean
echo [2] For Level 2 Clean
echo [exit] to exit
echo.
set /p option=
if %option% ==1 (goto Level1Clean)
if %option% ==2 (goto Level2Clean)
goto start
:Level1Clean
for /f "tokens=*" %%a in (CleanConfig.ini) do (
set parts=%%a
echo %parts%
REM FOR /f "tokens=1,2,3 delims=," %%a IN (%parts%) do echo %%a & echo %%b & echo %%c
)
:next
pause
goto end
Rem Example
:Example
for /f "tokens=*" %%a in (Lvl1Clean.txt) do (
Clean\%%a
)
pause
:end
There is still currently a bit missing from this file, but as for now it doesn't make a difference, as I am just working with the level 1 clean option for now. Under :Level1Clean I can easily get each line in the ini file to echo, and I were to add if the var equals an ini key then exit it works fine.
Where I'm having troubles is for some reason I am not able to set the "parts" variable to the line being extracted from the ini. When I turn echoing off to view what is going on it looks like it is being set just fine but when I echo "parts" it echos blank.
Sorry for the mess! So far this has been quickly set up and still needs to be cleaned up.
All help is appreciated! Thank you