kotkovets, вот заинтересовался созданием портативок по подобию PortableApps.com, и вот дошло дело до создания лаунчера...как я понимаю данная технология заключается в том что когда прога запускается лаунчер вносит необходимые изменения в систему, а когда закрыть, тот самый лаунчер удаляет все следы присутствия в системе (за исключения, понятно самих профилей или настроек которые хранятся непосредственно в папке портабла) вот нарыл скрипт лаунчера фоксит немного что переделал под неро (только в шапке и appinfo.ini) что бы проверить запустится ли), тело скрипта не трогал! Так вот непонятно где в скрипте вносить данные (который должны вносится в систему при запуске ...а где при завершении работы проги...не могли бы объяснить, вот сам код:
Код:
!define PORTABLEAPPNAME "Nero Express Portable"
!define NAME "Nero Express Portable"
!define APPNAME "NeroExpressPortable"
!define VER "12.0.28.001"
!define WEBSITE "repachok.net"
!define DEFAULTEXE "NeroExpress.exe"
!define DEFAULTAPPDIR "Nero"
!define DEFAULTSETTINGSDIR "settings"
!define LAUNCHERLANGUAGE "Russian"
;=== Program Details
Name "${PORTABLEAPPNAME}"
OutFile "..\..\${NAME}.exe"
Caption "${PORTABLEAPPNAME}"
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${PORTABLEAPPNAME}"
VIAddVersionKey CompanyName "repachok.net"
VIAddVersionKey LegalCopyright "REPACHOK GROUP"
VIAddVersionKey FileDescription "${PORTABLEAPPNAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${PORTABLEAPPNAME}"
VIAddVersionKey OriginalFilename "${NAME}.exe"
;VIAddVersionKey PrivateBuild ""
;VIAddVersionKey SpecialBuild ""
;=== Runtime Switches
CRCCheck On
WindowIcon Off
SilentInstall Silent
AutoCloseWindow True
RequestExecutionLevel user
; Best Compression
SetCompress Auto
SetCompressor /SOLID lzma
SetCompressorDictSize 32
SetDatablockOptimize On
;=== Include
;(Standard NSIS)
!include LogicLib.nsh
!include Registry.nsh
!include TextFunc.nsh
!insertmacro GetParameters
!include x64.nsh
;(NSIS Plugins)
!include TextReplace.nsh
;(Custom)
!include ReadINIStrWithDefault.nsh
!include ReplaceInFileWithTextReplace.nsh
;!include CheckForPlatformSplashDisable.nsh
;=== Program Icon
Icon "..\..\App\AppInfo\appicon.ico"
;=== Languages
;LoadLanguageFile "${NSISDIR}\Contrib\Language files\${LAUNCHERLANGUAGE}.nlf"
;!include PortableApps.comLauncherLANG_${LAUNCHERLANGUAGE}.nsh
Var PROGRAMDIRECTORY
Var SETTINGSDIRECTORY
Var ADDITIONALPARAMETERS
Var EXECSTRING
Var PROGRAMEXECUTABLE
Var INIPATH
Var SECONDARYLAUNCH
Var MISSINGFILEORPATH
Var LASTDRIVE
Var CURRENTDRIVE
Var FAILEDTORESTOREKEY
Var USERTYPE
Var RegKeyFDFExists
Var RegKeyPDFExists
Var RegKeyPDFIsBlank
Section "Main"
;=== Check if already running
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${NAME}") i .r1 ?e'
Pop $0
StrCmp $0 0 CheckINI
StrCpy $SECONDARYLAUNCH "true"
CheckINI:
;=== Find the INI file, if there is one
IfFileExists "$EXEDIR\${NAME}.ini" "" NoINI
StrCpy $INIPATH "$EXEDIR"
;=== Read the parameters from the INI file
${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Directory" "App\${DEFAULTAPPDIR}"
StrCpy $PROGRAMDIRECTORY "$EXEDIR\$0"
${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "SettingsDirectory" "Data\${DEFAULTSETTINGSDIR}"
StrCpy $SETTINGSDIRECTORY "$EXEDIR\$0"
${ReadINIStrWithDefault} $PROGRAMEXECUTABLE "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Executable" "${DEFAULTEXE}"
${ReadINIStrWithDefault} $ADDITIONALPARAMETERS "$INIPATH\${NAME}.ini" "${NAME}" "AdditionalParameters" ""
IfFileExists "$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" FoundProgramEXE NoProgramEXE
NoINI:
;=== No INI file, so we'll use the defaults
StrCpy $PROGRAMEXECUTABLE "${DEFAULTEXE}"
StrCpy $ADDITIONALPARAMETERS ""
IfFileExists "$EXEDIR\App\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" NoProgramEXE
StrCpy $PROGRAMDIRECTORY "$EXEDIR\App\${DEFAULTAPPDIR}"
StrCpy $SETTINGSDIRECTORY "$EXEDIR\Data\${DEFAULTSETTINGSDIR}"
Goto FoundProgramEXE
NoProgramEXE:
;=== Program executable not where expected
StrCpy $MISSINGFILEORPATH $PROGRAMEXECUTABLE
MessageBox MB_OK|MB_ICONEXCLAMATION `$(LauncherFileNotFound)`
Abort
FoundProgramEXE:
StrCmp $SECONDARYLAUNCH "true" GetPassedParameters
FindProcDLL::FindProc "${DEFAULTEXE}"
StrCmp $R0 "1" WarnAnotherInstance CheckSettings
WarnAnotherInstance:
MessageBox MB_OK|MB_ICONINFORMATION `$(LauncherAlreadyRunning)`
Abort
CheckSettings:
;=== Check for data files
IfFileExists "$SETTINGSDIRECTORY\*.*" GetPassedParameters
;=== Copy the default settings files
CreateDirectory "$SETTINGSDIRECTORY"
CopyFiles /SILENT "$EXEDIR\App\DefaultData\settings\*.*" "$SETTINGSDIRECTORY"
GetPassedParameters:
;=== Get any passed parameters
${GetParameters} $0
StrCmp "'$0'" "''" "" LaunchProgramParameters
;=== No parameters
StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE"`
Goto AdditionalParameters
LaunchProgramParameters:
StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" $0`
AdditionalParameters:
StrCmp $ADDITIONALPARAMETERS "" AdjustPaths
;=== Additional Parameters
StrCpy $EXECSTRING `$EXECSTRING $ADDITIONALPARAMETERS`
AdjustPaths:
StrCmp $SECONDARYLAUNCH "true" LaunchAndExit
ReadINIStr $LASTDRIVE "$SETTINGSDIRECTORY\${NAME}Settings.ini" "${NAME}Settings" "LastDrive"
${GetRoot} $EXEDIR $CURRENTDRIVE
StrCmp $LASTDRIVE $CURRENTDRIVE RegistryBackup
${ReplaceInFile} '$SETTINGSDIRECTORY\${NAME}.reg' '$LASTDRIVE\\' '$CURRENTDRIVE\\'
;StoreCurrentDriveLetter:
WriteINIStr "$SETTINGSDIRECTORY\${NAME}Settings.ini" "${NAME}Settings" "LastDrive" "$CURRENTDRIVE"
RegistryBackup:
;=== Backup the registry
${registry::KeyExists} "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader-BackupBy${NAME}" $R0
StrCmp $R0 "0" RestoreTheKey
${registry::KeyExists} "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader" $R0
StrCmp $R0 "-1" RestoreTheKey
${registry::MoveKey} "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader" "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader-BackupBy${NAME}" $R0
Sleep 100
RestoreTheKey:
IfFileExists "$SETTINGSDIRECTORY\${NAME}.reg" "" BackupHKLM
IfFileExists "$WINDIR\system32\reg.exe" "" RestoreTheKey9x
nsExec::ExecToStack `"$WINDIR\system32\reg.exe" import "$SETTINGSDIRECTORY\${NAME}.reg"`
Pop $R0
StrCmp $R0 '0' BackupHKLM ;successfully restored key
RestoreTheKey9x:
${registry::RestoreKey} "$SETTINGSDIRECTORY\${NAME}.reg" $R0
StrCmp $R0 '0' BackupHKLM ;successfully restored key
StrCpy $FAILEDTORESTOREKEY "true"
BackupHKLM:
UserInfo::GetAccountType
Pop $USERTYPE
StrCmp $USERTYPE "Guest" LaunchNow
StrCmp $USERTYPE "User" LaunchNow
${registry::MoveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.Document" "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.Document-BackupBy${NAME}" $R0
${registry::MoveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.FDFDoc" "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.FDFDoc-BackupBy${NAME}" $R0
${registry::MoveKey} "HKEY_CLASSES_ROOT\CLSID\{14E8BBD8-1D1C-4D56-A4DA-D20B75EB814E}" "HKEY_CLASSES_ROOT\CLSID\{14E8BBD8-1D1C-4D56-A4DA-D20B75EB814E}-BackupBy${NAME}" $R0
${registry::MoveKey} "HKEY_CLASSES_ROOT\CLSID\{A43F4073-BEBD-4142-B590-27A74384620B}" "HKEY_CLASSES_ROOT\CLSID\{A43F4073-BEBD-4142-B590-27A74384620B}-BackupBy${NAME}" $R0
${registry::KeyExists} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf" $R0
${If} $R0 == "0"
StrCpy $RegKeyPDFExists true
${registry::Read} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf" "" $R0 $R1
${If} $R0 == ""
StrCpy $RegKeyPDFIsBlank true
${EndIf}
${EndIf}
${registry::KeyExists} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.fdf" $R0
${If} $R0 == "0"
StrCpy $RegKeyFDFExists true
${EndIf}
LaunchNow:
Sleep 100
ExecWait $EXECSTRING
CheckRunning:
Sleep 1000
FindProcDLL::FindProc "$PROGRAMEXECUTABLE"
StrCmp $R0 "1" CheckRunning
StrCmp $FAILEDTORESTOREKEY "true" SetOriginalKeyBack
${registry::SaveKey} "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader" "$SETTINGSDIRECTORY\${NAME}.reg" "" $0
Sleep 100
SetOriginalKeyBack:
${registry::DeleteKey} "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader" $R0
${registry::KeyExists} "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader-BackupBy${NAME}" $R0
Sleep 100
StrCmp $R0 "-1" CleanupHKLM
${registry::MoveKey} "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader-BackupBy${NAME}" "HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader" $R0
Sleep 100
Goto CleanupHKLM
CleanupHKLM:
StrCmp $USERTYPE "Guest" RegistryCleanup
StrCmp $USERTYPE "User" RegistryCleanup
${registry::DeleteKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.Document" $R0
${registry::MoveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.Document-BackupBy${NAME}" "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.Document" $R0
${registry::DeleteKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.FDFDoc" $R0
${registry::MoveKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.FDFDoc-BackupBy${NAME}" "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FoxitReader.FDFDoc" $R0
${registry::DeleteKey} "HKEY_CLASSES_ROOT\CLSID\{14E8BBD8-1D1C-4D56-A4DA-D20B75EB814E}" $R0
${registry::MoveKey} "HKEY_CLASSES_ROOT\CLSID\{14E8BBD8-1D1C-4D56-A4DA-D20B75EB814E}-BackupBy${NAME}" "HKEY_CLASSES_ROOT\CLSID\{14E8BBD8-1D1C-4D56-A4DA-D20B75EB814E}" $R0
${registry::DeleteKey} "HKEY_CLASSES_ROOT\CLSID\{A43F4073-BEBD-4142-B590-27A74384620B}" $R0
${registry::MoveKey} "HKEY_CLASSES_ROOT\CLSID\{A43F4073-BEBD-4142-B590-27A74384620B}-BackupBy${NAME}" "HKEY_CLASSES_ROOT\CLSID\{A43F4073-BEBD-4142-B590-27A74384620B}" $R0
${If} $RegKeyPDFExists != true
${registry::DeleteKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf" $R0
${EndIf}
${If} $RegKeyPDFIsBlank == true
${registry::Read} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf" "" $R0 $R1
${If} $R0 != ""
${registry::DeleteValue} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf" "" $R0
${EndIf}
${EndIf}
${If} $RegKeyFDFExists != true
${registry::DeleteKey} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.fdf" $R0
${EndIf}
RegistryCleanup:
;=== Cleanup the registry
${registry::DeleteKeyEmpty} "HKEY_CURRENT_USER\Software\Foxit Software" $R0
Goto TheEnd
LaunchAndExit:
Exec $EXECSTRING
TheEnd:
${registry::Unload}
newadvsplash::stop /WAIT
SectionEnd
Спасибо!
Тоесть как бы не понятно на каком этапе скрипта выполняются команды для внесения изменений в систему а на каком наоборот удаления этих изменений..
Или может можно как то упростить сие чудо (как бы две секции в одной команды запуска в другой команды по завершению работы проги)