+ - / * in CMD
#1
Posted 22 August 2009 - 11:43 AM
#2
Posted 22 August 2009 - 12:15 PM
How i can do in CMD + - / *?
well lets say you have to variable and you want to + them into a new one
set /a x=1 set /a y=2 set /a z=%x%+%y%
i hope that helped
#3
Posted 22 August 2009 - 12:21 PM
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 by Mr_Smartepants, 22 August 2009 - 12:23 PM.
#4
Posted 22 August 2009 - 05:07 PM
#5
Posted 22 August 2009 - 07:29 PM
THX, i will try it. I want use it with IF...well lets say you have to variable and you want to + them into a new one
set /a x=1 set /a y=2 set /a z=%x%+%y%
i hope that helped
if "%I%" == "2" DO set ULT=%I%+1Will this work?
#6
Posted 22 August 2009 - 07:32 PM
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 mode
and in that if you don't need the do
so the code well be simple
if "%I%" == "2" set /a ULT=%I%+1
and in that way
wouldn't it be easy to make the last code like that
if "%I%" == "2" set /a ULT+=3
it would do the same trick
ULT+=3 mean add on ULT 3 and it also equal ULT=%ULT%+3
edit :
sorry for the last code i made it wrong the one i made would add
so it should be
if "%I%" == "2" set /a ULT=3
my mistake
Edited by DaRk MaDnEsS, 22 August 2009 - 07:53 PM.
#7
Posted 22 August 2009 - 08:24 PM
well you need to add /a after set
that will active math mode
and in that if you don't need the do
so the code well be simpleif "%I%" == "2" set /a ULT=%I%+1
and in that way
wouldn't it be easy to make the last code like thatif "%I%" == "2" set /a ULT+=3
it would do the same trick
ULT+=3 mean add on ULT 3 and it also equal ULT=%ULT%+3
edit :
sorry for the last code i made it wrong the one i made would add
so it should beif "%I%" == "2" set /a ULT=3
my mistake
Tomorow i will work on my W7I CMD and will try it THX
EDIT:
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 :_Error
EDIT2:
Does somebody know how read how many files (*.rar, *.zip, etc etc..) are in folder?
Edited by George King, 22 August 2009 - 09:04 PM.
#8
Posted 22 August 2009 - 11:02 PM
that should workTomorow i will work on my W7I CMD and will try it THX
EDIT:
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 :_Error
EDIT2:
Does somebody know how read how many files (*.rar, *.zip, etc etc..) are in folder?
if not "%MSU%" == "1" if not "%CAB%" == "1" goto :_Error
LOL yeah me
i will test the code and tell you
edit:
made it
set count=0
for /f %%a in ('dir /b *.exe') do set /a count+=1
echo %count%
Edited by DaRk MaDnEsS, 22 August 2009 - 11:28 PM.
#9
Posted 23 August 2009 - 07:00 AM
@echo off
title Windows 7 Updates Installer by George King v1.1.0
cls
if exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Pack
echo.
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
)
:_CAB
echo.
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
)
:_Test
if not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates
:_Install
echo.
echo ***************************************************
echo * Press any key for start updating your system... *
echo ***************************************************
pause >nul
cls
echo.
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 >nul
exit
:_NoUpdates
echo.
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 >nul
exit
#10
Posted 23 August 2009 - 07:11 AM
Thanks Darky... Your script work, but in my script work only for *.cab. Dont know why...
@echo off title Windows 7 Updates Installer by George King v1.1.0 cls if exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Pack echo. 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 ) :_CAB echo. 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 ) :_Test if not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates :_Install echo. echo *************************************************** echo * Press any key for start updating your system... * echo *************************************************** pause >nul cls echo. 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 >nul exit :_NoUpdates echo. 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 >nul exit
well in for it will not run in the first code like you want
it will run like this
set /a COUNT+=1 <<will work fine
set M=1 << will work like that and wouldn't change
so let the for do the job and take the number when it's done
try this one now
@echo off
title Windows 7 Updates Installer by George King v1.1.0
cls
if exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Pack
echo.
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
)
:_CAB
echo.
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
)
:_Test
if not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates
:_Install
echo.
echo ***************************************************
echo * Press any key for start updating your system... *
echo ***************************************************
pause >nul
cls
echo.
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 >nul
exit
:_NoUpdates
echo.
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 >nul
exit
Edited by DaRk MaDnEsS, 23 August 2009 - 07:13 AM.
#11
Posted 23 August 2009 - 07:30 AM
@echo off
title Windows 7 Updates Installer by George King v1.1.0
cls
if exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Pack
echo.
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
)
:_CAB
echo.
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
)
:_Test
if not "%MSU%" == "1" if not "%CAB%" == "1" goto goto :_NoUpdates
:_Install
echo.
echo ***************************************************
echo * Press any key for start updating your system... *
echo ***************************************************
pause >nul
cls
echo.
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 >nul
exit
:_NoUpdates
echo.
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 >nul
exitThe script found updates, but no read ho many MSU files are in folder... For CAB files it work...
#12
Posted 23 August 2009 - 07:35 AM
try to replace if exist Windows6.1-*.msu with if exist *.msu
and remove @echo off
and make a pause after each section so see if it works fine or not
#13
Posted 23 August 2009 - 05:01 PM
mm that is wired
try to replace if exist Windows6.1-*.msu with if exist *.msu
and remove @echo off
and make a pause after each section so see if it works fine or not
@echo off
title Windows 7 Updates Installer by George King v1.1.0
cls
if exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Pack
echo.
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
)
:_USRCH
for /f %%a in ('dir /b Windows6.1-*.msu') DO set /a COUNT=%COUNT%+1
goto :_UOK
:_CAB
echo.
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
)
:_CSRCH
for /f %%b in ('dir /b *.cab') DO set /a COUNT=%COUNT%+1
goto :_COK
:_Test
if not "%MSU%" == "1" if not "%CAB%" == "1" goto :_NoUpdates
:_Install
echo.
echo ***************************************************
echo * Press any key for start updating your system... *
echo ***************************************************
pause >nul
cls
echo.
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 >nul
exit
:_NoUpdates
echo.
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 >nul
exitNow it work, too many goto and ifs for this small appz
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 by George King, 23 August 2009 - 05:05 PM.
#14
Posted 23 August 2009 - 05:07 PM
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 mode
if 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 edit
try it this way
if 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
)
:_USRCH
for /f %%a in ('dir /b *.msu') DO set /a COUNT=%COUNT%+1
goto :_UOK
Edited by DaRk MaDnEsS, 23 August 2009 - 05:09 PM.
#15
Posted 23 August 2009 - 08:05 PM
@echo off
title Windows 7 Updates Installer by George King v1.1.0
cls
if exist Windows6.1-KB968771-x*.msu set IE=- IE 8 Feature Pack
echo.
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
)
:_USRCH
for /f %%a in ('dir /b Windows6.1-*.msu') DO set /a count+=1
goto :_UOK
:_CAB
echo.
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
)
:_CSRCH
for /f %%b in ('dir /b *.cab') DO set /a coun+=1
goto :_COK
:_Test
if not "%MSU%" == "1" if not "%CAB%" == "1" goto :_NoUpdates
:_Install
echo.
set /a TOT=%COUNT%+%COUN%
echo Found totaly %TOT% updates
echo.
echo.
echo ***************************************************
echo * Press any key for start updating your system... *
echo ***************************************************
pause >nul
cls
echo.
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 >nul
exit
:_NoUpdates
echo.
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 >nul
exitThanks for your help Darky ;-)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













