Jump to content

Recommended Posts

Posted

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

Posted (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 by Mr_Smartepants
Posted

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

THX, i will try it. I want use it with IF...

if "%I%" == "2" DO set ULT=%I%+1

Will this work?

Posted (edited)

THX, i will try it. I want use it with IF...

if "%I%" == "2" DO set ULT=%I%+1

Will 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 :blink:

Edited by DaRk MaDnEsS
Posted (edited)

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 :blink:

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 :_Error

I 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
Posted (edited)

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 :_Error

I 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?

that should work

if not "%MSU%" == "1" if not "%CAB%" == "1" goto :_Error

LOL yeah me :D

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
Posted

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

Posted (edited)

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
Posted

@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

The script found updates, but no read ho many MSU files are in folder... For CAB files it work...

Posted

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

Posted (edited)

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
exit

Now 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 by George King
Posted (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 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
Posted

Now it allready work :naughty:

@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
exit

Thanks for your help Darky ;-)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...