Имя пользователя:
Пароль:
 | Правила  

Компьютерный форум OSzone.net » Программирование, базы данных и автоматизация действий » Скриптовые языки администрирования Windows » CMD/BAT - Поясните работу двух скриптов.

Ответить
Настройки темы
CMD/BAT - Поясните работу двух скриптов.

Аватара для Pozia

Ветеран


Сообщения: 2756
Благодарности: 211

Профиль | Отправить PM | Цитировать


Есть вот такие скрипты для обновления программы:

Код: Выделить весь код
@echo off
rem ===========================================================================
rem
rem Script Name:        UGS_UPDATE.BAT
rem
rem This script updates files for NX products.
rem The script should be run from a command prompt window.
rem
rem ===========================================================================
rem
rem Copyright (c) 1995-2007 UGS Corp. All Rights Reserved
rem
rem ===========================================================================
rem Revision History:
rem
rem RELEASE   AUTHOR      DATE     COMMENT
rem =======   ======      =======  =======
rem 4.0.1.1   R. Baxter   25JAN06  Initial version for NX 4.0.1 
rem 4.0.1.1   R. Baxter   27JAN06  Add checks for x86/AMD64 update scenarios.
rem 4.0.1.2   R. Baxter   16FEB06  Chng platform cks to look for p4libs dir.
rem 4.0.1.3   R. Baxter   19MAR06  Version change only.
rem 4.0.2.1   R. Baxter   09MAY06  Version change only.
rem 4.0.2.2   R. Baxter   06JUN06  Version change only.
rem 4.0.3.2   R. Baxter   15Aug06  Version nums & disable cacls commands.
rem 4.0.3.3   R. Baxter   25Sep06  Version change only.
rem 4.0.3.3   K. Hafen    26Oct06  Remove psapi.dll so IE7 will work
rem 4.0.4.1   R. Baxter   26Mar07  Version change and add %SCRIPTDIR logic.
rem 5.0.1.1   R. Baxter   12Apr07  Tweak Copy kits subroutine to use $SCRIPTDIR.
rem 5.0.1.2   R. Baxter   30Apr07  Version change only.
rem ===========================================================================


rem Initial setup and checks. _______________________________________________

rem Version control variables. 

rem Version number of this Maintenance Release (MR) or Maintenance Pack (MP).
set VERSION=5.0.0.25

rem Minimum installed NX version required. MR's use the Base release num, but
rem the version & min_version must be equal for MP's.
set MIN_VERSION=5.0.0.25

rem Version title. Displayed text only. may be different than version num.
set TEXT_VERSION=%VERSION% Maintenance Pack 1.

rem Max_version must always be set to version to prevent version downgrades.
set MAX_VERSION=%VERSION%

rem Set platform specific variable for this update. Can be either x86 or AMD64.
set REQUIRED_PLATFORM=x86

rem Set the system path for this script.
set PATH=%PATH%;%SystemRoot%\system32

rem Save the full path to this script. NX 4.0.4.1
rem the %~dp0 gives path of %0 and the for /f line removes trailing slash.
pushd %~dp0
for /f "tokens=*" %%I in ('cd') do set SCRIPTDIR=%%I
popd

rem Begin initial checks. ____________________________________________________

rem Check UGII_BASE_DIR ______________________________________________________
rem Check and massage the setting for %UGII_BASE_DIR%
rem See if UGII_BASE_DIR environment variable is set, if not abort.
if not defined UGII_BASE_DIR goto no_base_dir
rem 
rem Next, set a short var name to make the scripting easier. And also, 
rem strip any quotation marks. The :"= operator strips out the quotes. 
rem Then we can use BASE (with or without quotes) as needed.
set BASE=%UGII_BASE_DIR:"=%
rem 
rem Check if UGII_BASE_DIR (using %BASE%) actually exists, if not, abort.
if not exist "%BASE%" goto no_ug
rem
rem Now cd into %BASE% to strip the trailing slash if it has one. The 'cd'
rem command will return %BASE% with no trailing slash. Added NX 3.0.1.3.
pushd "%BASE%"
for /f "tokens=*" %%I in ('cd') do set BASE=%%I
popd
rem End %UGII_BASE_DIR% dir checks. __________________________________________

rem Check PLATFORM _________________________________________________ NX 4.0.1.2
rem This update can contain either 32 bit or 64 bit software. Must make sure 
rem the user is installing this update on the same type of software that is
rem already installed in %UGII_BASE_DIR%. If not - we must exit.
rem Note: Checking %PROCESSOR_ARCHITECTURE is unreliable so must ck for p4libs.
rem Look for %BASE%\ugii\p4libs folder - it only exists on 32 bit.
rem
rem if p4libs exists base dir must have 32 bit software else its 64 bit.
if exist "%BASE%"\ugii\p4libs (
   set INSTALLED_PLATFORM=x86
) else (
   set INSTALLED_PLATFORM=AMD64
)
if not "%REQUIRED_PLATFORM%" == "%INSTALLED_PLATFORM%" goto wrong_platform_exit
rem End Platform checks. _____________________________________________________

rem Check that we can find env_print in %BASE%.
if not exist "%BASE%"\ugii\env_print.exe goto no_env_print
rem End env_print check. _____________________________________________________

rem Check the 4 digit version number. Added NX20501.
set REV=""
rem First set NX_REV from the output of env_print -n.
for /f "tokens=*" %%I in (' "%BASE%\ugii\env_print" -n ') do set NX_REV=%%I
rem Next strip off any letters or spaces.
set NX_REV=%NX_REV:V=% 
set NX_REV=%NX_REV:NX=% 
set NX_REV=%NX_REV: =%
rem Now compare NX_REV to the minimum and maximum versions. 
if %NX_REV% GTR %MAX_VERSION% goto wrong_ug_version
if %NX_REV% LSS %MIN_VERSION% goto wrong_ug_version
rem End Version checks._______________________________________________________

rem Check for /v or /d switches. The /d switch added in V2.0.5.1
rem
rem Check for the verbose switch.  Default is set to no messages.
rem The Q_SWT is used by xcopy and V_SWT is used by sfx images.
rem Defaults are set to quiet or silent.
set Q_SWT=/q  &  set V_SWT=-silent
if /I (%1) == (-v) ( set Q_SWT=/f & set V_SWT= )
if /I (%1) == (/v) ( set Q_SWT=/f & set V_SWT= )
if /I (%1) == (v)  ( set Q_SWT=/f & set V_SWT= )
if /I (%2) == (-v) ( set Q_SWT=/f & set V_SWT= )
if /I (%2) == (/v) ( set Q_SWT=/f & set V_SWT= )
if /I (%2) == (v)  ( set Q_SWT=/f & set V_SWT= )
rem
rem Check for the (/d) switch.  If set we dont ask questions. V2.0.5.1
set D_SWT=
if /I (%1) == (-d)   set D_SWT=/d
if /I (%1) == (/d)   set D_SWT=/d
if /I (%1) == (d)    set D_SWT=/d
if /I (%2) == (-d)   set D_SWT=/d
if /I (%2) == (/d)   set D_SWT=/d
if /I (%2) == (d)    set D_SWT=/d
rem End switches checks. ____________________________________________________


rem MAIN ____________________________________________________________________


rem All checks look o.k. give a startup message if not turned of by /d. 
if "%D_SWT%" == "/d" (
  cls
  echo Installing NX %TEXT_VERSION% files 
  echo in: "%BASE%"
  echo.
) else (
  cls
  echo This script will install NX %TEXT_VERSION% files 
  echo in: "%BASE%"
  echo.
  echo Enter Cntrl-C to abort or & pause
  echo. & echo. 
)
rem _________________________________________________________________________


rem Perform Pre-Copy Custom Actions _________________________________________
rem
rem None needed for 5.0.1.1
rem
rem End of Custom Actions ___________________________________________________


rem Copy the kits. __________________________________________________________
rem This routine makes a list of all the subdirectories in the QRM/IRM 
rem directory then calls the copy_kits subroutine and passes the kit name.
echo.
echo Copying files. Please wait . . .
echo. & echo.
rem Reset the COPY_ERRORS flag
set COPY_ERRORS=
rem
rem Make a list of all the kits then call copy_kits for each one.
rem Push dir to %SCRIPTDIR before making the list. NX 4.0.4.1
rem Further tweak to 5.0.1.1. Do dir /b of full path instead of cd to dir.
rem pushd %SCRIPTDIR%
rem for /F %%K in ('dir /b *') do call :copy_kits %%K
for /F %%K in ('dir /b "%SCRIPTDIR%"\*') do call :copy_kits %%K
popd
rem End of Copy the kits. ___________________________________________________


rem Perform Post-Copy Custom Actions ________________________________________
rem
rem None needed for 5.0.1.1
rem
rem End of Custom Actions ___________________________________________________


rem Set UG file permissions. _________________________________________________
rem
rem Disabled in 4.0.3.2.
rem echo.
rem echo Setting file permissions . . .
rem if "%COMPUTERNAME%" == "%USERDOMAIN%" (
rem    cacls "%BASE%" /t /e /c /p ADMINISTRATOR:F ADMINISTRATORS:F EVERYONE:R > NUL
rem ) else (
rem    cacls "%BASE%" /t /e /c /p ADMINISTRATOR:F ADMINISTRATORS:F "DOMAIN ADMINS":F   EVERYONE:R > NUL
rem )
rem _________________________________________________________________________


rem Set Registry requirements. ______________________________________________
rem
if exist "%BASE%"\install\DeleteRegDBValue.exe (
   echo Updating Registry . . .  &  echo.
   "%BASE%"\install\DeleteRegDBValue.exe "SOFTWARE\Unigraphics Solutions\Installed Applications" "%BASE%"  >NUL 2>&1
)
rem _________________________________________________________________________


rem Give a completion message. ______________________________________________
rem Check for any xcopy errors and give the appropriate message.
echo.
if defined COPY_ERRORS (
   echo ERROR:  One or more files failed to update. These errors may be caused
   echo by a sharing violation on open files in the destination directory.
   echo Review the output text for specific file information.
   echo.
   echo Close all files in the destination and re-run ugs_update.
   echo.
   echo The following kits had update errors:
   echo %COPY_ERRORS%
) else (
   echo.
   echo DONE. %0 has completed successfully !
)


rem This the LOGICAL END of the SCRIPT.
echo.
goto end_update
rem _________________________________________________________________________



rem _______ SUBROUTINES _____________________________________________________


rem Copy kits. ______________________________________________________________
rem This is where we actually do the copies or extractions.
rem Updated NX 2.0.2.1 28JAN04 to use sfx images instead of xcopy.
rem Updated NX 2.0.2.2 02FEB04 to use sfx images or xcopy.

:copy_kits

  rem set KIT var to arg1 to get a recognizable var name.
  set KIT=%1%

  rem check for a null argument and if so just return.
  if not defined KIT goto :EOF

  rem set DIR to just the kit name. strip off the extension.
  set DIR=%~n1

  rem set EXT to just the extension. strip off the kit name.
  set EXT=%~x1

  rem now check if there is a kit folder in base dir if not just return.
  if not exist "%BASE%"\%DIR%  goto :EOF

  rem Now do the sfx or xcopy. If arg1 had an extension do the sfx method.
  rem if arg1 had no extension just do a regular xcopy.
  if defined EXT (
     echo Updating files in "%BASE%"\%DIR% . . .
     rem Must remove any read-only attributes cuz sfx wont overwrite.
     attrib -R "%BASE%"\%DIR%\* /S /D > NUL
     rem New method for 2.0.2.1 using self extracting files.
     %KIT% -extract -directories -overwrite %V_SWT% "%BASE%"
     if errorlevel 1 (
        set COPY_ERRORS=%COPY_ERRORS% %DIR%
        echo ERROR updating %DIR%
     ) else (
        echo Updated %DIR%
     )
  rem if no extension so use the old xcopy method.
  ) else (
     echo Updating files in "%BASE%"\%DIR% . . .
     xcopy  /i/e/k/h/r/y%Q_SWT%  %KIT%  "%BASE%"\%KIT%
     if errorlevel 1 (
        set COPY_ERRORS=%COPY_ERRORS% %DIR%
        echo ERROR updating %DIR%
     ) else (
        echo Updated %DIR%
     )
  )
  echo. & echo. 

goto :EOF
rem ________________________________________________________________________



rem Error handlers __________________________________________________________ 

:no_base_dir
cls
echo.
echo The NX environment variable %%UGII_BASE_DIR%% is not defined.
echo Please install NX before running %0.
echo.
goto end_update

:no_env_print
cls
echo.
echo The folder defined by the variable %%UGII_BASE_DIR%% does not
echo appear to contain the 'env_print.exe' program needed by %0.
echo.
echo Check that "%BASE%"\ugii\env_print.exe exists before running %0.
echo.
goto end_update

:no_ug
cls
echo.
echo NX does not appear to be installed on this system. The folder defined
echo by the variable %%UGII_BASE_DIR%% does NOT exist.
echo.
echo Please install NX before running %0.
echo.
goto end_update

:wrong_ug_version 
rem Display error message appropriate for update or patch.
cls
echo.
echo The NX folder defined in the environment variable %%UGII_BASE_DIR%% 
echo appears to be the wrong version. 
echo.
echo %%UGII_BASE_DIR%% is set to: %UGII_BASE_DIR%
echo The detected version is: %NX_REV%
echo.
if %MIN_VERSION% EQU %MAX_VERSION% (
  echo The installed NX version must be: %MIN_VERSION%
) else (
  echo The installed NX version must be within the following range:
  echo Minimum: %MIN_VERSION%  -  Maximum: %MAX_VERSION%
)
echo.
echo Set %%UGII_BASE_DIR%% to the correct folder and re-run %0.
echo.
goto end_update

:wrong_platform_exit
cls
echo.
echo ERROR:
echo.
echo This update contains files for machine type: %REQUIRED_PLATFORM%
echo The previously installed files appear to be type: %INSTALLED_PLATFORM%
echo.
echo Check that you are installing the right version of this update for the
echo files contained in: %BASE%
echo.
goto end_update

:wrong_platform_warning
cls
echo.
echo The software contained in this update is 32 Bit software.  Your machine
echo hardware appears to be 64 Bit hardware (%PROCESSOR_ARCHITECTURE%).
echo.
echo Please check that you are using the correct version of this update
echo for the NX software you are updating.
echo.
echo Enter Cntrl-C to abort or & pause
echo.
goto :EOF


:end_update
if not "%D_SWT%" == "/d" pause
@echo on
Код: Выделить весь код
@echo off
rem ===========================================================================
rem
rem Script Name:        UGS_UPDATE.BAT
rem
rem This script updates files for NX products.
rem The script should be run from a command prompt window.
rem
rem ===========================================================================
rem
rem Copyright (c) 1995-2007 UGS Corp. All Rights Reserved
rem
rem ===========================================================================
rem Revision History:
rem
rem RELEASE   AUTHOR      DATE     COMMENT
rem =======   ======      =======  =======
rem 4.0.1.1   R. Baxter   25JAN06  Initial version for NX 4.0.1 
rem 4.0.1.1   R. Baxter   27JAN06  Add checks for x86/AMD64 update scenarios.
rem 4.0.1.2   R. Baxter   16FEB06  Chng platform cks to look for p4libs dir.
rem 4.0.1.3   R. Baxter   19MAR06  Version change only.
rem 4.0.2.1   R. Baxter   09MAY06  Version change only.
rem 4.0.2.2   R. Baxter   06JUN06  Version change only.
rem 4.0.3.2   R. Baxter   15Aug06  Version nums & disable cacls commands.
rem 4.0.3.3   R. Baxter   25Sep06  Version change only.
rem 4.0.3.3   K. Hafen    26Oct06  Remove psapi.dll so IE7 will work
rem 4.0.4.1   R. Baxter   26Mar07  Version change and add %SCRIPTDIR logic.
rem 5.0.1.1   R. Baxter   12Apr07  Tweak Copy kits subroutine to use $SCRIPTDIR.
rem 5.0.1.2   R. Baxter   30Apr07  Version change only.
rem 5.0.1.3   R. Baxter   22May07  Version change only.
rem 5.0.1.4   R. Baxter   19Jun07  Version change only.
rem ===========================================================================


rem Initial setup and checks. _______________________________________________

rem Version control variables. 

rem Version number of this Maintenance Release (MR) or Maintenance Pack (MP).
set VERSION=5.0.1.4

rem Minimum installed NX version required. MR's use the Base release num, but
rem the version & min_version must be equal for MP's.
set MIN_VERSION=5.0.0.0

rem Version title. Displayed text only. may be different than version num.
set TEXT_VERSION=%VERSION% Maintenance Release

rem Max_version must always be set to version to prevent version downgrades.
set MAX_VERSION=%VERSION%

rem Set platform specific variable for this update. Can be either x86 or AMD64.
set REQUIRED_PLATFORM=x86

rem Set the system path for this script.
set PATH=%PATH%;%SystemRoot%\system32

rem Save the full path to this script. NX 4.0.4.1
rem the %~dp0 gives path of %0 and the for /f line removes trailing slash.
pushd %~dp0
for /f "tokens=*" %%I in ('cd') do set SCRIPTDIR=%%I
popd

rem Begin initial checks. ____________________________________________________

rem Check UGII_BASE_DIR ______________________________________________________
rem Check and massage the setting for %UGII_BASE_DIR%
rem See if UGII_BASE_DIR environment variable is set, if not abort.
if not defined UGII_BASE_DIR goto no_base_dir
rem 
rem Next, set a short var name to make the scripting easier. And also, 
rem strip any quotation marks. The :"= operator strips out the quotes. 
rem Then we can use BASE (with or without quotes) as needed.
set BASE=%UGII_BASE_DIR:"=%
rem 
rem Check if UGII_BASE_DIR (using %BASE%) actually exists, if not, abort.
if not exist "%BASE%" goto no_ug
rem
rem Now cd into %BASE% to strip the trailing slash if it has one. The 'cd'
rem command will return %BASE% with no trailing slash. Added NX 3.0.1.3.
pushd "%BASE%"
for /f "tokens=*" %%I in ('cd') do set BASE=%%I
popd
rem End %UGII_BASE_DIR% dir checks. __________________________________________

rem Check PLATFORM _________________________________________________ NX 4.0.1.2
rem This update can contain either 32 bit or 64 bit software. Must make sure 
rem the user is installing this update on the same type of software that is
rem already installed in %UGII_BASE_DIR%. If not - we must exit.
rem Note: Checking %PROCESSOR_ARCHITECTURE is unreliable so must ck for p4libs.
rem Look for %BASE%\ugii\p4libs folder - it only exists on 32 bit.
rem
rem if p4libs exists base dir must have 32 bit software else its 64 bit.
if exist "%BASE%"\ugii\p4libs (
   set INSTALLED_PLATFORM=x86
) else (
   set INSTALLED_PLATFORM=AMD64
)
if not "%REQUIRED_PLATFORM%" == "%INSTALLED_PLATFORM%" goto wrong_platform_exit
rem End Platform checks. _____________________________________________________

rem Check that we can find env_print in %BASE%.
if not exist "%BASE%"\ugii\env_print.exe goto no_env_print
rem End env_print check. _____________________________________________________

rem Check the 4 digit version number. Added NX20501.
set REV=""
rem First set NX_REV from the output of env_print -n.
for /f "tokens=*" %%I in (' "%BASE%\ugii\env_print" -n ') do set NX_REV=%%I
rem Next strip off any letters or spaces.
set NX_REV=%NX_REV:V=% 
set NX_REV=%NX_REV:NX=% 
set NX_REV=%NX_REV: =%
rem Now compare NX_REV to the minimum and maximum versions. 
if %NX_REV% GTR %MAX_VERSION% goto wrong_ug_version
if %NX_REV% LSS %MIN_VERSION% goto wrong_ug_version
rem End Version checks._______________________________________________________

rem Check for /v or /d switches. The /d switch added in V2.0.5.1
rem
rem Check for the verbose switch.  Default is set to no messages.
rem The Q_SWT is used by xcopy and V_SWT is used by sfx images.
rem Defaults are set to quiet or silent.
set Q_SWT=/q  &  set V_SWT=-silent
if /I (%1) == (-v) ( set Q_SWT=/f & set V_SWT= )
if /I (%1) == (/v) ( set Q_SWT=/f & set V_SWT= )
if /I (%1) == (v)  ( set Q_SWT=/f & set V_SWT= )
if /I (%2) == (-v) ( set Q_SWT=/f & set V_SWT= )
if /I (%2) == (/v) ( set Q_SWT=/f & set V_SWT= )
if /I (%2) == (v)  ( set Q_SWT=/f & set V_SWT= )
rem
rem Check for the (/d) switch.  If set we dont ask questions. V2.0.5.1
set D_SWT=
if /I (%1) == (-d)   set D_SWT=/d
if /I (%1) == (/d)   set D_SWT=/d
if /I (%1) == (d)    set D_SWT=/d
if /I (%2) == (-d)   set D_SWT=/d
if /I (%2) == (/d)   set D_SWT=/d
if /I (%2) == (d)    set D_SWT=/d
rem End switches checks. ____________________________________________________


rem MAIN ____________________________________________________________________


rem All checks look o.k. give a startup message if not turned of by /d. 
if "%D_SWT%" == "/d" (
  cls
  echo Installing NX %TEXT_VERSION% files 
  echo in: "%BASE%"
  echo.
) else (
  cls
  echo This script will install NX %TEXT_VERSION% files 
  echo in: "%BASE%"
  echo.
  echo Enter Cntrl-C to abort or & pause
  echo. & echo. 
)
rem _________________________________________________________________________


rem Perform Pre-Copy Custom Actions _________________________________________
rem
rem None needed for 5.0.1.1
rem
rem End of Custom Actions ___________________________________________________


rem Copy the kits. __________________________________________________________
rem This routine makes a list of all the subdirectories in the QRM/IRM 
rem directory then calls the copy_kits subroutine and passes the kit name.
echo.
echo Copying files. Please wait . . .
echo. & echo.
rem Reset the COPY_ERRORS flag
set COPY_ERRORS=
rem
rem Make a list of all the kits then call copy_kits for each one.
rem Push dir to %SCRIPTDIR before making the list. NX 4.0.4.1
rem Further tweak to 5.0.1.1. Do dir /b of full path instead of cd to dir.
rem pushd %SCRIPTDIR%
rem for /F %%K in ('dir /b *') do call :copy_kits %%K
for /F %%K in ('dir /b "%SCRIPTDIR%"\*') do call :copy_kits %%K
popd
rem End of Copy the kits. ___________________________________________________


rem Perform Post-Copy Custom Actions ________________________________________
rem
rem None needed for 5.0.1.1
rem
rem End of Custom Actions ___________________________________________________


rem Set UG file permissions. _________________________________________________
rem
rem Disabled in 4.0.3.2.
rem echo.
rem echo Setting file permissions . . .
rem if "%COMPUTERNAME%" == "%USERDOMAIN%" (
rem    cacls "%BASE%" /t /e /c /p ADMINISTRATOR:F ADMINISTRATORS:F EVERYONE:R > NUL
rem ) else (
rem    cacls "%BASE%" /t /e /c /p ADMINISTRATOR:F ADMINISTRATORS:F "DOMAIN ADMINS":F   EVERYONE:R > NUL
rem )
rem _________________________________________________________________________


rem Set Registry requirements. ______________________________________________
rem
if exist "%BASE%"\install\DeleteRegDBValue.exe (
   echo Updating Registry . . .  &  echo.
   "%BASE%"\install\DeleteRegDBValue.exe "SOFTWARE\Unigraphics Solutions\Installed Applications" "%BASE%"  >NUL 2>&1
)
rem _________________________________________________________________________


rem Give a completion message. ______________________________________________
rem Check for any xcopy errors and give the appropriate message.
echo.
if defined COPY_ERRORS (
   echo ERROR:  One or more files failed to update. These errors may be caused
   echo by a sharing violation on open files in the destination directory.
   echo Review the output text for specific file information.
   echo.
   echo Close all files in the destination and re-run ugs_update.
   echo.
   echo The following kits had update errors:
   echo %COPY_ERRORS%
) else (
   echo.
   echo DONE. %0 has completed successfully !
)


rem This the LOGICAL END of the SCRIPT.
echo.
goto end_update
rem _________________________________________________________________________



rem _______ SUBROUTINES _____________________________________________________


rem Copy kits. ______________________________________________________________
rem This is where we actually do the copies or extractions.
rem Updated NX 2.0.2.1 28JAN04 to use sfx images instead of xcopy.
rem Updated NX 2.0.2.2 02FEB04 to use sfx images or xcopy.

:copy_kits

  rem set KIT var to arg1 to get a recognizable var name.
  set KIT=%1%

  rem check for a null argument and if so just return.
  if not defined KIT goto :EOF

  rem set DIR to just the kit name. strip off the extension.
  set DIR=%~n1

  rem set EXT to just the extension. strip off the kit name.
  set EXT=%~x1

  rem now check if there is a kit folder in base dir if not just return.
  if not exist "%BASE%"\%DIR%  goto :EOF

  rem Now do the sfx or xcopy. If arg1 had an extension do the sfx method.
  rem if arg1 had no extension just do a regular xcopy.
  if defined EXT (
     echo Updating files in "%BASE%"\%DIR% . . .
     rem Must remove any read-only attributes cuz sfx wont overwrite.
     attrib -R "%BASE%"\%DIR%\* /S /D > NUL
     rem New method for 2.0.2.1 using self extracting files.
     %KIT% -extract -directories -overwrite %V_SWT% "%BASE%"
     if errorlevel 1 (
        set COPY_ERRORS=%COPY_ERRORS% %DIR%
        echo ERROR updating %DIR%
     ) else (
        echo Updated %DIR%
     )
  rem if no extension so use the old xcopy method.
  ) else (
     echo Updating files in "%BASE%"\%DIR% . . .
     xcopy  /i/e/k/h/r/y%Q_SWT%  %KIT%  "%BASE%"\%KIT%
     if errorlevel 1 (
        set COPY_ERRORS=%COPY_ERRORS% %DIR%
        echo ERROR updating %DIR%
     ) else (
        echo Updated %DIR%
     )
  )
  echo. & echo. 

goto :EOF
rem ________________________________________________________________________



rem Error handlers __________________________________________________________ 

:no_base_dir
cls
echo.
echo The NX environment variable %%UGII_BASE_DIR%% is not defined.
echo Please install NX before running %0.
echo.
goto end_update

:no_env_print
cls
echo.
echo The folder defined by the variable %%UGII_BASE_DIR%% does not
echo appear to contain the 'env_print.exe' program needed by %0.
echo.
echo Check that "%BASE%"\ugii\env_print.exe exists before running %0.
echo.
goto end_update

:no_ug
cls
echo.
echo NX does not appear to be installed on this system. The folder defined
echo by the variable %%UGII_BASE_DIR%% does NOT exist.
echo.
echo Please install NX before running %0.
echo.
goto end_update

:wrong_ug_version 
rem Display error message appropriate for update or patch.
cls
echo.
echo The NX folder defined in the environment variable %%UGII_BASE_DIR%% 
echo appears to be the wrong version. 
echo.
echo %%UGII_BASE_DIR%% is set to: %UGII_BASE_DIR%
echo The detected version is: %NX_REV%
echo.
if %MIN_VERSION% EQU %MAX_VERSION% (
  echo The installed NX version must be: %MIN_VERSION%
) else (
  echo The installed NX version must be within the following range:
  echo Minimum: %MIN_VERSION%  -  Maximum: %MAX_VERSION%
)
echo.
echo Set %%UGII_BASE_DIR%% to the correct folder and re-run %0.
echo.
goto end_update

:wrong_platform_exit
cls
echo.
echo ERROR:
echo.
echo This update contains files for machine type: %REQUIRED_PLATFORM%
echo The previously installed files appear to be type: %INSTALLED_PLATFORM%
echo.
echo Check that you are installing the right version of this update for the
echo files contained in: %BASE%
echo.
goto end_update

:wrong_platform_warning
cls
echo.
echo The software contained in this update is 32 Bit software.  Your machine
echo hardware appears to be 64 Bit hardware (%PROCESSOR_ARCHITECTURE%).
echo.
echo Please check that you are using the correct version of this update
echo for the NX software you are updating.
echo.
echo Enter Cntrl-C to abort or & pause
echo.
goto :EOF


:end_update
if not "%D_SWT%" == "/d" pause
@echo on
Как я вижу в процессе обновления эти батники просто копируют файлы в папку с программой. Так ли это? Делают ли они еще что нибудь? Может что в реестр вносят или еще что?

Отправлено: 20:53, 11-12-2009

 


Компьютерный форум OSzone.net » Программирование, базы данных и автоматизация действий » Скриптовые языки администрирования Windows » CMD/BAT - Поясните работу двух скриптов.

Участник сейчас на форуме Участник сейчас на форуме Участник вне форума Участник вне форума Автор темы Автор темы Шапка темы Сообщение прикреплено

Похожие темы
Название темы Автор Информация о форуме Ответов Последнее сообщение
Есть возможность устроиться на работу по сборке компов.Потяну ли эту работу ? teapot08 Флейм 27 17-01-2010 14:15
Поясните значение нескольких параметров соединения jorikello Хочу все знать 4 06-08-2009 05:14
[решено] Поясните настройки кодирования кодека DivX 6 Megacucumber Видео и аудио: обработка и кодирование 1 17-01-2008 10:25
[решено] Поясните плиз с командами cmd в Windows pingUIN Хочу все знать 14 06-06-2007 15:26
поясните, плиз: What is this? Demiurg Общий по FreeBSD 11 29-03-2005 08:46




 
Переход