Guest Posted August 22, 2009 Posted August 22, 2009 How i can do in CMD + - / *?well lets say you have to variable and you want to + them into a new oneset /a x=1set /a y=2set /a z=%x%+%y%i hope that helped Quote
Mr_Smartepants Posted August 22, 2009 Posted August 22, 2009 (edited) Characters with special meaning for the interpreter must be prefixed by a caret (^) to behave as normal ones. so type ^&.Or enclose the text with quotes: copy /y "%systemdrive%\test\*" "%systemdrive%\test2\*"*Edit,Oh, nevermind. I just caught you want to add, subtract, multiply & divide.Dark Madness got it. Edited August 22, 2009 by Mr_Smartepants Quote
ricktendo Posted August 22, 2009 Posted August 22, 2009 You could maybe convert to OEM chars, It works for me & letters like á, é, í, ó, ú Quote
George King Posted August 22, 2009 Author Posted August 22, 2009 well lets say you have to variable and you want to + them into a new oneset /a x=1set /a y=2set /a z=%x%+%y%i hope that helpedTHX, i will try it. I want use it with IF...if "%I%" == "2" DO set ULT=%I%+1Will this work? Quote
Guest Posted August 22, 2009 Posted August 22, 2009 (edited) THX, i will try it. I want use it with IF...if "%I%" == "2" DO set ULT=%I%+1Will this work?well you need to add /a after set that will active math modeand in that if you don't need the do so the code well be simple if "%I%" == "2" set /a ULT=%I%+1and in that way wouldn't it be easy to make the last code like thatif "%I%" == "2" set /a ULT+=3it would do the same trick ULT+=3 mean add on ULT 3 and it also equal ULT=%ULT%+3edit :sorry for the last code i made it wrong the one i made would addso it should be if "%I%" == "2" set /a ULT=3my mistake Edited August 22, 2009 by DaRk MaDnEsS Quote
George King Posted August 22, 2009 Author Posted August 22, 2009 (edited) well you need to add /a after set that will active math modeand in that if you don't need the do so the code well be simple if "%I%" == "2" set /a ULT=%I%+1and in that way wouldn't it be easy to make the last code like thatif "%I%" == "2" set /a ULT+=3it would do the same trick ULT+=3 mean add on ULT 3 and it also equal ULT=%ULT%+3edit :sorry for the last code i made it wrong the one i made would addso it should be if "%I%" == "2" set /a ULT=3my mistake Tomorow i will work on my W7I CMD and will try it THXEDIT:Sorry, i have 1 question how make this:if not "%MSU%" == "1" and "%CAB%" == "1" goto :_ErrorI think if MSU and CAB not 1 goto :_ErrorEDIT2:Does somebody know how read how many files (*.rar, *.zip, etc etc..) are in folder? Edited August 22, 2009 by George King Quote
Guest Posted August 22, 2009 Posted August 22, 2009 (edited) Tomorow i will work on my W7I CMD and will try it THXEDIT:Sorry, i have 1 question how make this:if not "%MSU%" == "1" and "%CAB%" == "1" goto :_ErrorI think if MSU and CAB not 1 goto :_ErrorEDIT2:Does somebody know how read how many files (*.rar, *.zip, etc etc..) are in folder?that should work if not "%MSU%" == "1" if not "%CAB%" == "1" goto :_ErrorLOL yeah me i will test the code and tell youedit:made it set count=0for /f %%a in ('dir /b *.exe') do set /a count+=1echo %count% Edited August 22, 2009 by DaRk MaDnEsS Quote
George King Posted August 23, 2009 Author Posted August 23, 2009 Thanks Darky... Your script work, but in my script work only for *.cab. Dont know why...@echo offtitle Windows 7 Updates Installer by George King v1.1.0clsif exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Packecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.echo.echo Searching for MSU Updates...echo.echo.if exist Windows6.1-*.msu (set MSU=1 set COUNT=0 for /f %%a in ('dir /b *.msu') DO (set /a COUNT+=1 set M=%COUNT% ) echo. echo Windows 7 Updates Installer found %M% * MSU * Updates echo. goto :_CAB ) ELSE (echo ******* echo No * MSU * Updates in current folder... echo ******* goto :_CAB ):_CABecho.echo Searching for CAB Updates...echo.echo.if exist *.cab (set CAB=1 set COUNT=0 for /f %%b in ('dir /b *.cab') DO (set /a COUNT+=1 set C=%COUNT% ) echo. echo Windows 7 Updates Installer found %COUNT% * CAB * Updates echo. goto :_Install ) ELSE (echo ******* echo No * CAB * Updates in current folder... echo ******* goto :_Test ) :_Testif not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates:_Installecho.echo ***************************************************echo * Press any key for start updating your system... *echo ***************************************************pause >nulclsecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.if "%MSU%" == "1" (echo Installing MSU Update: FOR %%U IN (*.msu) DO (echo %%U %IE% "%%U" /quiet /norestart ) )echo.if "%CAB%" == "1" (echo Installing CAB Update: FOR %%C IN (*.cab) DO (echo %%C DISM /Online /Add-Package /PackagePath:%%C >nul ) )echo.echo Please REBOOT your computer for complete installation...pause >nulexit:_NoUpdatesecho.echo Updates not found!!!echo.echo Please place this file (Update.exe) into folder with MSU or/and CAB updates...echo After place Update.exe into folder with updates installation will start...echo.pause >nulexit Quote
Guest Posted August 23, 2009 Posted August 23, 2009 (edited) Thanks Darky... Your script work, but in my script work only for *.cab. Dont know why...@echo offtitle Windows 7 Updates Installer by George King v1.1.0clsif exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Packecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.echo.echo Searching for MSU Updates...echo.echo.if exist Windows6.1-*.msu (set MSU=1 set COUNT=0 for /f %%a in ('dir /b *.msu') DO (set /a COUNT+=1 set M=%COUNT% ) echo. echo Windows 7 Updates Installer found %M% * MSU * Updates echo. goto :_CAB ) ELSE (echo ******* echo No * MSU * Updates in current folder... echo ******* goto :_CAB ):_CABecho.echo Searching for CAB Updates...echo.echo.if exist *.cab (set CAB=1 set COUNT=0 for /f %%b in ('dir /b *.cab') DO (set /a COUNT+=1 set C=%COUNT% ) echo. echo Windows 7 Updates Installer found %COUNT% * CAB * Updates echo. goto :_Install ) ELSE (echo ******* echo No * CAB * Updates in current folder... echo ******* goto :_Test ) :_Testif not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates:_Installecho.echo ***************************************************echo * Press any key for start updating your system... *echo ***************************************************pause >nulclsecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.if "%MSU%" == "1" (echo Installing MSU Update: FOR %%U IN (*.msu) DO (echo %%U %IE% "%%U" /quiet /norestart ) )echo.if "%CAB%" == "1" (echo Installing CAB Update: FOR %%C IN (*.cab) DO (echo %%C DISM /Online /Add-Package /PackagePath:%%C >nul ) )echo.echo Please REBOOT your computer for complete installation...pause >nulexit:_NoUpdatesecho.echo Updates not found!!!echo.echo Please place this file (Update.exe) into folder with MSU or/and CAB updates...echo After place Update.exe into folder with updates installation will start...echo.pause >nulexitwell in for it will not run in the first code like you want it will run like this set /a COUNT+=1 <<will work fineset M=1 << will work like that and wouldn't changeso let the for do the job and take the number when it's donetry this one now @echo offtitle Windows 7 Updates Installer by George King v1.1.0clsif exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Packecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.echo.echo Searching for MSU Updates...echo.echo.if exist Windows6.1-*.msu (set MSU=1 set COUNT=0 for /f %%a in ('dir /b *.msu') DO set /a COUNT+=1 set M=%COUNT% echo. echo Windows 7 Updates Installer found %M% * MSU * Updates echo. goto :_CAB ) ELSE (echo ******* echo No * MSU * Updates in current folder... echo ******* goto :_CAB ):_CABecho.echo Searching for CAB Updates...echo.echo.if exist *.cab (set CAB=1 set COUNT=0 for /f %%b in ('dir /b *.cab') DO set /a COUNT+=1 set C=%COUNT% echo. echo Windows 7 Updates Installer found %COUNT% * CAB * Updates echo. goto :_Install ) ELSE (echo ******* echo No * CAB * Updates in current folder... echo ******* goto :_Test ) :_Testif not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates:_Installecho.echo ***************************************************echo * Press any key for start updating your system... *echo ***************************************************pause >nulclsecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.if "%MSU%" == "1" (echo Installing MSU Update: FOR %%U IN (*.msu) DO (echo %%U %IE% "%%U" /quiet /norestart ) )echo.if "%CAB%" == "1" (echo Installing CAB Update: FOR %%C IN (*.cab) DO (echo %%C DISM /Online /Add-Package /PackagePath:%%C >nul ) )echo.echo Please REBOOT your computer for complete installation...pause >nulexit:_NoUpdatesecho.echo Updates not found!!!echo.echo Please place this file (Update.exe) into folder with MSU or/and CAB updates...echo After place Update.exe into folder with updates installation will start...echo.pause >nulexit Edited August 23, 2009 by DaRk MaDnEsS Quote
George King Posted August 23, 2009 Author Posted August 23, 2009 @echo offtitle Windows 7 Updates Installer by George King v1.1.0clsif exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Packecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.echo.echo Searching for MSU Updates...echo.echo.if exist Windows6.1-*.msu (set MSU=1 set COUNT=0 for /f %%a in ('dir /b *.msu') DO set /a COUNT+=1 set M=%COUNT% echo. echo Windows 7 Updates Installer found %M% * MSU * Updates echo. goto :_CAB ) ELSE (echo ******* echo No * MSU * Updates in current folder... echo ******* goto :_CAB ):_CABecho.echo Searching for CAB Updates...echo.echo.if exist *.cab (set CAB=1 set COUNT=0 for /f %%b in ('dir /b *.cab') DO set /a COUNT+=1 set C=%COUNT% echo. echo Windows 7 Updates Installer found %COUNT% * CAB * Updates echo. goto :_Install ) ELSE (echo ******* echo No * CAB * Updates in current folder... echo ******* goto :_Test ) :_Testif not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates:_Installecho.echo ***************************************************echo * Press any key for start updating your system... *echo ***************************************************pause >nulclsecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.if "%MSU%" == "1" (echo Installing MSU Update: FOR %%U IN (*.msu) DO (echo %%U %IE% "%%U" /quiet /norestart ) )echo.if "%CAB%" == "1" (echo Installing CAB Update: FOR %%C IN (*.cab) DO (echo %%C DISM /Online /Add-Package /PackagePath:%%C >nul ) )echo.echo Please REBOOT your computer for complete installation...pause >nulexit:_NoUpdatesecho.echo Updates not found!!!echo.echo Please place this file (Update.exe) into folder with MSU or/and CAB updates...echo After place Update.exe into folder with updates installation will start...echo.pause >nulexitThe script found updates, but no read ho many MSU files are in folder... For CAB files it work... Quote
Guest Posted August 23, 2009 Posted August 23, 2009 mm that is wired try to replace if exist Windows6.1-*.msu with if exist *.msuand remove @echo off and make a pause after each section so see if it works fine or not Quote
George King Posted August 23, 2009 Author Posted August 23, 2009 (edited) mm that is wired try to replace if exist Windows6.1-*.msu with if exist *.msuand remove @echo off and make a pause after each section so see if it works fine or not@echo offtitle Windows 7 Updates Installer by George King v1.1.0clsif exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Packecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.echo.echo Searching for MSU Updates...echo.echo.if exist Windows6.1-*.msu (set MSU=1 goto :_USRCH :_UOK echo. echo Windows 7 Updates Installer found %COUNT% * MSU * Updates echo. goto :_CAB ) ELSE (echo ******* echo No * MSU * Updates in current folder... echo ******* goto :_CAB ):_USRCHfor /f %%a in ('dir /b Windows6.1-*.msu') DO set /a COUNT=%COUNT%+1goto :_UOK:_CABecho.echo Searching for CAB Updates...echo.echo.if exist *.cab (set CAB=1 goto :_CSRCH :_COK echo. echo Windows 7 Updates Installer found %COUNT% * CAB * Updates echo. goto :_Install ) ELSE (echo ******* echo No * CAB * Updates in current folder... echo ******* goto :_Test ) :_CSRCHfor /f %%b in ('dir /b *.cab') DO set /a COUNT=%COUNT%+1goto :_COK:_Testif not "%MSU%" == "1" if not "%CAB%" == "1" goto :_NoUpdates:_Installecho.echo ***************************************************echo * Press any key for start updating your system... *echo ***************************************************pause >nulclsecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.if "%MSU%" == "1" (echo Installing MSU Update: FOR %%U IN (*.msu) DO (echo %%U %IE% "%%U" /quiet /norestart ) )echo.if "%CAB%" == "1" (echo Installing CAB Update: FOR %%C IN (*.cab) DO (echo %%C DISM /Online /Add-Package /PackagePath:%%C >nul ) )echo.echo Please REBOOT your computer for complete installation...pause >nulexit:_NoUpdatesecho.echo Updates not found!!!echo.echo Please place this file (Update.exe) into folder with MSU or/and CAB updates...echo After place Update.exe into folder with updates installation will start...echo.pause >nulexitNow it work, too many goto and ifs for this small appz :sweatingbullets:EDIT: There must be a mistake in MSU code... In Folder with 19 msu files it say 1 updates found, but in folder where are 2 CAB it say 2 updates found Edited August 23, 2009 by George King Quote
Guest Posted August 23, 2009 Posted August 23, 2009 (edited) great for you :thumbsup_anim: hmm seems that the if can't run for in it if it got two many lines"i will note my self next time"well you can small it a bit with a call function modeif you want i can make the same cmd but with function and other commands you will find it less << if you want >>edit:about your edittry it this wayif exist *.msu (set MSU=1 goto :_USRCH :_UOK echo. echo Windows 7 Updates Installer found %COUNT% * MSU * Updates echo. goto :_CAB ) ELSE (echo ******* echo No * MSU * Updates in current folder... echo ******* goto :_CAB ):_USRCHfor /f %%a in ('dir /b *.msu') DO set /a COUNT=%COUNT%+1goto :_UOK Edited August 23, 2009 by DaRk MaDnEsS Quote
George King Posted August 23, 2009 Author Posted August 23, 2009 Now it allready work :naughty: @echo offtitle Windows 7 Updates Installer by George King v1.1.0clsif exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Packecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.echo.echo Searching for MSU Updates...echo.if exist Windows6.1-*.msu (set MSU=1 goto :_USRCH :_UOK echo. echo Found %COUNT% * MSU * Updates echo. goto :_CAB ) ELSE (echo ******* echo No * MSU * Updates in current folder... echo ******* goto :_CAB ):_USRCHfor /f %%a in ('dir /b Windows6.1-*.msu') DO set /a count+=1goto :_UOK:_CABecho.echo Searching for CAB Updates...echo.if exist *.cab (set CAB=1 goto :_CSRCH :_COK echo. echo Found %COUN% * CAB * Updates echo. goto :_Install ) ELSE (echo ******* echo No * CAB * Updates in current folder... echo ******* goto :_Test ) :_CSRCHfor /f %%b in ('dir /b *.cab') DO set /a coun+=1goto :_COK:_Testif not "%MSU%" == "1" if not "%CAB%" == "1" goto :_NoUpdates:_Installecho.set /a TOT=%COUNT%+%COUN%echo Found totaly %TOT% updates echo.echo.echo ***************************************************echo * Press any key for start updating your system... *echo ***************************************************pause >nulclsecho.echo +++++++++++++++++++++++++++++++echo + Windows 7 Updates Installer +echo +++++++++++++++++++++++++++++++echo.if "%MSU%" == "1" (echo Installing MSU Update: FOR %%U IN (*.msu) DO (echo %%U %IE% "%%U" /quiet /norestart ) )echo.if "%CAB%" == "1" (echo Installing CAB Update: FOR %%C IN (*.cab) DO (echo %%C DISM /Online /Add-Package /PackagePath:%%C >nul ) )echo.echo Please REBOOT your computer for complete installation...pause >nulexit:_NoUpdatesecho.echo Updates not found!!!echo.echo Please place this file (Update.exe) into folder with MSU or/and CAB updates...echo After place Update.exe into folder with updates installation will start...echo.pause >nulexitThanks for your help Darky ;-) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.