Archive: Why my install is blocked by svchost.exe


Why my install is blocked by svchost.exe
Hello. Why my setup exe is blocked by svchost.exe (I know it from LockHunter
which cannot unlock) after finished instaling. When I change OutFile line in
script below and add some text before filename because old name is locked and
cannot be overwritten I can delete setup file. Old setup can be deleted only
after reboot. I turned off KAV 2010 anti virus but it do not help. I'm using
NSIS 2.46 under Windows 7 (64 bit) with SP 1 and I have UAC turned off.
Please help me. The sctipy is below. And sorry for my bad English.

!define FILESSOURCEPATH "D:\UPLOAD\WINUAE\"
Section
SetOutPath "$INSTDIR\HARD_DISKS"
File /r "${FILESSOURCEPATH}HARD_DISKS\Demos"
File /r "${FILESSOURCEPATH}HARD_DISKS\HD-Games"
SectionEnd

!define APPDIR "WINUAE_WITH_TINY_LAUNCHER"
!define APPEXE "winuae_tl.exe"
!define APPNAME "WinUAE + Tiny Launcher + Demos + Games"
!define SETUPEXE "tl_games_and_demos_setup.exe"
!define WINUAEREGKEY "Software\_Tiny_Launcher_WinUAE"
!define TLCONFIGFILE "CONFIGURATIONS\!_tl.winuae"
!define MUI_WELCOMEPAGE_TITLE_3LINES

!include "MUI.nsh"
!include "nsDialogs.nsh"

Var DIALOG
Var MESSAGE

; The name of the installer
Name "${APPNAME}"

; The output file to write
OutFile D:\${SETUPEXE}

; The default installation directory
InstallDir $PROGRAMFILES\${APPDIR}

; Request application privileges for Windows Vista
RequestExecutionLevel user

;--------------------------------

; Pages

!insertmacro MUI_PAGE_WELCOME

; Custom page
Page custom AboutSetupContent

; Installer pages
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Launch WinUAE + Tiny Launcher"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchApp"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

;--------------------------------

; own custom page

Function AboutSetupContent

nsDialogs::Create 1018
Pop $DIALOG
!insertmacro MUI_HEADER_TEXT "About $(^NameDA) package." "This setup and its contents was prepared by olesio."
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 10 30 500 300 "\
Following package contains WinUAE - Amiga Emulator for Windows in a little\
bit changed version and special configuration file. Also it contain\
Kickstart 3.1 ROM Image and hard disk file (*.hdf) with Tiny Launcher\
written by user called GIBS from EAB (http://eab.abime.net). I also\
included: Demoscene productions and popular games. Both in WHDLoad\
versions. This package license is no warranty. WARNING! One very\
important thing: you MUST own legal registered WHDLoad key and\
copyrighted Amiga Kickstart ROM version 3.1 file to use this setup!\
Enjoy and please visit TheCompany World Wide Web Page at:\
http://thecompany.pl for many Amiga Games as easy to use executables."
Pop $MESSAGE
nsDialogs::Show

FunctionEnd

Function LaunchApp
ExecShell "" "$INSTDIR\${APPEXE}"
FunctionEnd

; The stuff to install

Section "Required files" Section1

SectionIn RO

; Put files there
SetOverwrite on
SetOutPath "$INSTDIR\CONFIGURATIONS"
File "${FILESSOURCEPATH}${TLCONFIGFILE}"
SetOutPath "$INSTDIR\ROMS"
File "${FILESSOURCEPATH}ROMS\kick31.rom"
SetOutPath "$INSTDIR\HARD_DISKS"
File "${FILESSOURCEPATH}HARD_DISKS\4_tiny_launcher.hdf"
SetOutPath $INSTDIR
File "${FILESSOURCEPATH}${APPEXE}"

; Write WinUAE paths
WriteRegStr HKCU "${WINUAEREGKEY}\DetectedROMs" "ROM_015" 'KS ROM v3.1 (A1200) rev 40.68 (512k) [391773-01/391774-01] / "$INSTDIR\ROMS\kick31.rom"'
WriteRegStr HKCU "${WINUAEREGKEY}" "KickstartPath" "$INSTDIR\Roms\"
WriteRegStr HKCU "${WINUAEREGKEY}" "hdfPath" "$INSTDIR\HARD_DISKS\"
WriteRegStr HKCU "${WINUAEREGKEY}" "ConfigurationPath" "$INSTDIR\Configurations\"
WriteRegStr HKCU "${WINUAEREGKEY}" "ScreenshotPath" "$INSTDIR\Screenshots\"
WriteRegStr HKCU "${WINUAEREGKEY}" "StatefilePath" "$INSTDIR\Savestates\"
WriteRegStr HKCU "${WINUAEREGKEY}" "SaveimagePath" "$INSTDIR\SaveImages\"
WriteRegStr HKCU "${WINUAEREGKEY}" "VideoPath" "$INSTDIR\"
WriteRegStr HKCU "${WINUAEREGKEY}" "InputPath" "$INSTDIR\Inputrecordings\"
WriteRegStr HKCU "${WINUAEREGKEY}" "RipperPath" "$INSTDIR\"
WriteRegDWORD HKCU "${WINUAEREGKEY}" "QuickStartModel" 4
WriteRegDWORD HKCU "${WINUAEREGKEY}" "ConfigurationCache" 0
WriteRegDWORD HKCU "${WINUAEREGKEY}" "QuickStartConfiguration" 1
WriteRegDWORD HKCU "${WINUAEREGKEY}" "QuickStartCompatibility" 1

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPDIR}" "DisplayName" "${APPNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPDIR}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPDIR}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPDIR}" "NoRepair" 1
WriteUninstaller "uninstall.exe"

SectionEnd

; Optional section (can be disabled by the user)

Section "Desktop shortcut" Section2

CreateShortCut "$DESKTOP\Run ${APPNAME}.lnk" "$INSTDIR\${APPEXE}" "" "$INSTDIR\${APPEXE}" 0

SectionEnd

Section "Start menu shortcut" Section3
CreateDirectory "$SMPROGRAMS\${APPNAME}"
CreateShortCut "$SMPROGRAMS\${APPNAME}\Run ${APPNAME}.lnk" "$INSTDIR\${APPEXE}" "-f .\${TLCONFIGFILE}" "$INSTDIR\${APPEXE}" 0
CreateShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0

SectionEnd

;--------------------------------
; Descriptions

LangString DESC_Section1 ${LANG_ENGLISH} "WinUAE emulator (in changed version) and other required package files (configuration, kickstart, hdf file with TIny Launcher, Demos and Games)."
LangString DESC_Section2 ${LANG_ENGLISH} "Creates a shortcut on the Desktop."
LangString DESC_Section3 ${LANG_ENGLISH} "Creates a subdirectory with shortcuts in the Start Menu."

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------

; Uninstaller

Section "Uninstall"

; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPDIR}"
DeleteRegKey HKCU "${WINUAEREGKEY}"

; Remove files and uninstaller
RMDir /r $INSTDIR
Delete $INSTDIR\uninstall.exe

; Remove shortcuts, if any
Delete "$DESKTOP\Run ${APPNAME}.lnk"
Delete "$SMPROGRAMS\${APPNAME}\*.*"

; Remove directories used
RMDir "$SMPROGRAMS\${APPNAME}"
RMDir "$INSTDIR"

SectionEnd

Never had this problem before but I've never used that anti-virus either. What if you output as notepad.exe instead? Also you should !include MUI2.nsh instead of MUI.nsh (MUI2 uses nsDialogs which you are already using).

Stu


Hmmm when I named notepad.exe I can easly change after install so file is not locked. But when I named before sss.exe pft.exe or similar I have problem with lock. Maybe is other reason why in 99% of cases first file will be blocked but after changing filename and copy by Sgift+F5 under Total Commander the new file after install is not blocked.

EDIT: hmmm I do not know why but now under name winuae_tiny_launcher_setup.exe everything is fine. So thank you for hint with filename and wit MUI2.


Same problem here
Hi guys,

I also have this problem, the svchost.exe is locking my installer file after I install the application. I can't unlocking it and can't recompile the script as the output cannot be written.

I have KAV but it's disabled. I'm running Windows 7 Enterprise 32bit and I use Eclipse as IDE for writing NSIS script.

Thanks in advance for any suggestions,
Daniel


I have this problem also.

I'm using Windows 7 Ultimate 64-bit, no anti-virus or suchlike installed.

The first install triggers an svchost process that sits at 25% CPU usage. If I kill that process then I can recompile, otherwise the output file cannot be overwritten.

Been using NSIS for other projects on the same machine with no problems. Current installer isn't hugely different to what I have done before.


Attach your script or a minimum script which reproduces the problem.

Stu


I've found the source of the problem but not a solution. My installer includes an MSI file that installs some of our software components. It looks like that .msi (driven by InstallShield) isn't completing cleanly and it's leaving a rogue msiexec process behind.

I'm using ExecWait to run the .msi - is there a better way?

Thanks,

Mark


Actually, my previous post was incorrect.

I changed the name of the Outfile as suggested in an earlier post and that seems to have fixed it.

Previously the filename was similar to:

"blahblahblah Setup v1.2.exe"

Changing it to:

"blahblahblah Setup.exe" fixed it.

Weird!


This is a bit late, but we have run into an issue where the "Windows Defender" service is responsible for locking files. Stopping the Windows defender service releases the lock and you do not have to reboot. The Windows Defender service is running as an svchost.exe in task manager.


Ok, but I do not use Windows Defender. Only KAV 2010 is working as antivirus software in background.