Skip to content
⌘ NSIS Forum Archive

Files disappearing once installation is complete

21 posts

frohlinger#

Files disappearing once installation is complete

Hi,

Below is my small NSIS script (I omitted the uninstallation section).

There are 5 files that disappear (!) immediately after the installation completes.
I have no idea why...
I see them in the program files directory while the installation is running, but when it finishes - all files are deleted, while all the rest remain.
These are new files I've added today to my existing NSIS installation.

BTW, If I rename the files and add the PRODUCT_VERSION to them - they are not deleted.
But I do NOT want to version them...

The "disappearing" files are:
RemoveTabs.exe
abouttabs.htm
search.gif
search_bg.gif
search_bg_color.gif

What am I missing here?
Best,
Gabriela



!define PRODUCT_VERSION "1.0.9"
!define PRODUCT_NAME "GRAZEit.IE.Plugin"
Name "${PRODUCT_NAME}"
OutFile "${PRODUCT_NAME}.${PRODUCT_VERSION}_home.exe"
InstallDir "$PROGRAMFILES\IE.Plugin"
!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
AutoCloseWindow true

Section "Files"
SetOutPath "$INSTDIR"

File "/oname=HomeInstaller.${PRODUCT_VERSION}.exe" "bin\HomeInstaller.exe"
File "/oname=PreInstaller.${PRODUCT_VERSION}.exe" "bin\PreInstaller.exe"
File "/oname=PostInstaller.${PRODUCT_VERSION}.exe" "bin\PostInstaller.exe"
File "/oname=PostUnInstall.${PRODUCT_VERSION}.exe" "bin\PostUnInstall.exe"
File "bin\login.png"

File "bin\RemoveTabs.exe"
File "abouttabs\abouttabs.htm"
File "abouttabs\search.gif"
File "abouttabs\search_bg.gif"
File "abouttabs\search_bg_color.gif"

execwait "$INSTDIR\HomeInstaller.${PRODUCT_VERSION}.exe"
execwait "$INSTDIR\PreInstaller.${PRODUCT_VERSION}.exe" $0

File "/oname=giInternetExplorer.${PRODUCT_VERSION}.dll" "bin\giInternetExplorer.dll"
File "/oname=giWindow.${PRODUCT_VERSION}.dll" "bin\giWindow.dll"

RegDll "$INSTDIR\giInternetExplorer.${PRODUCT_VERSION}.dll"

WriteUninstaller $INSTDIR\uninstaller.exe
WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayName" "${PRODUCT_NAME}"
WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayIcon" "$INSTDIR\uninstaller.exe"
WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr HKLM "${REG_UNINSTALL}" "Publisher" "GRAZEit"
WriteRegDWord HKLM "${REG_UNINSTALL}" "NoModify" 1
WriteRegDWord HKLM "${REG_UNINSTALL}" "NoRepair" 1
WriteRegStr HKLM "${REG_UNINSTALL}" "UninstallString" '"$INSTDIR\uninstaller.exe"'

exec '"$INSTDIR\PostInstaller.${PRODUCT_VERSION}.exe" ${PRODUCT_VERSION}'
SectionEnd
Highcoder#
File "bin\RemoveTabs.exe"
File "abouttabs\abouttabs.htm"
File "abouttabs\search.gif"
File "abouttabs\search_bg.gif"
File "abouttabs\search_bg_color.gif"
Strange...

Maybe you should use full paths like "C:\mysetupfiles\abouttabs\search_bg_color.gif".
Or the postinstaller do something with this files...

When renaming works for you then "rename" it ;-)

File "/oname=search_bg_color.gif" "abouttabs\search_bg_color.gif"
frohlinger#
Oh my good.... you're right.
I had a DeleteFile in the postinstaller removing files that are not versioned, in order to perform clean upgrades....
All is good now. Thank you!!!
CharlesH#
Hi, I am getting a similar problem to this. I am downloading a file on my second last 'page' of the installer. When I click on the next button of that page, the installer hangs for about 30 seconds - unresponsive is shown in the window top banner if you try to move the window. The file downloads quick enough, but then disappears after the 30 second period, then the installer moves to the final page.

If I make a copy of the file manually during that 30 second period, the copy stays, but the original goes. Using NSIS to copy or rename does not work. The copied/renamed file also disappears. The file copy bit (current version of code provided below) does not seem to do anything.

I have an expired version of McAfee security. I have had a browse in both McAfee and windows security and cannot find any sign that they are deleting the file.

I am a complete noob at this, so it might be something obvious.

Here is the code snipped for the second last page:

Var Dialog
Page Custom MyCustomPage2
Function MyCustomPage2
MessageBox MB_OK "Some text."
Exec "$INSTDIR\${MAIN_APP_EXE}"
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 40u "Label text"
${NSD_CreateButton} 0 40u 100% 24u "Button 1 text"
#Pop $Button
${NSD_CreateButton} 0 68u 100% 24u "Button 2 text"
#Pop $Button
${NSD_CreateLabel} 0 92u 100% 12u " Button 2 note"
${NSD_CreateButton} 0 108u 100% 24u "Button 3 text"
#Pop $Button
nsDialogs::Show
NSISdl::download "https://www.url.com/test.txt" "C:\path\test.txt"
CopyFiles "C:\path\test.txt" "C:\path\test2.txt"
FunctionEnd
Anders#
You should not perform large file operations outside Sections.

That being said, I don't see anything here that would delete a file. What does Process Monitor say? Which process is deleting?
CharlesH#
Click image for larger version

Name:	process monitor.png
Views:	113
Size:	11.3 KB
ID:	4635822

Screenshot attached. From what I can gather, it is being created twice, the second time with a 'disposition' to delete. No idea what that means.

The downloads are optional and I want to control when the option appears. Not sure how to get them into a section.
Anders#
And it is also using posix semantics which is unusual for NSIS. Can you try it on another machine or in a VM/Windows Sandbox with a different Anti-Virus?
CharlesH#
I tried on a different computer with a different anti virus program and got similar results. See attached.

Are there any examples around of how to do this properly, with the code in a section?

One of the files I hope to download this way is 2.8 GB. Is that too big to work?


Click image for larger version

Name:	process monitor 2nd pc.png
Views:	153
Size:	74.6 KB
ID:	4635972
Anders#
Is your example code accurate? NSISdl does not support HTTPS, only HTTP. Perhaps you need to use InetC instead?
CharlesH#
Yes the example code is accurate, in the sense that it is what I am using. I only change the paths. But it is part of a larger script.
Anders#
Works just fine for me. Edit my code until it fails for you...
RequestExecutionLevel User
!include nsDialogs.nsh
Page custom MyPageCreate
Page InstFiles
Function MyPageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 0 100% 40u "You are not supposed to perform download/file operations on a page..."
Pop $0
nsDialogs::Show
NSISdl::download "http://web.archive.org/web/2000/http://www.rfc-editor.org/rfc/rfc20.txt" "$pluginsdir\nsisdl.txt" ; NOTE: HTTP not HTTPS
Pop $0
inetc::get "httpS://www.rfc-editor.org/rfc/rfc20.txt" "$pluginsdir\inetc.txt" /END
Pop $0
FunctionEnd
Section
ExecShellWait "" "$pluginsdir\nsisdl.txt"
ExecShellWait "" "$pluginsdir\inetc.txt"
HideWindow
Sleep 3333
Quit
SectionEnd 
CharlesH#edited
I can't get your code to compile. I think I am using the latest version.

Also, I suspect you are trying to get it to download a file for compiling. I want it to download an installation executable for the end user. I am making use of at least one, probably several third party installers. The first one is needed by every user, so I include that one in the compiled setup file. The next one depends on the user's situation, and some of the options are over 2GB, so I am trying to add to buttons that they can click to download the one they need. Bonus points if NSIS can execute it after download, but for now I am just trying to get the download happening.

This is what I get from the compiler:

MakeNSIS v3.10 - Copyright 1999-2023 Contributors
See the file COPYING for license details.
Credits can be found in the Users Manual.

...

!define: "MUI_INSERT_NSISCONF"=""

Changing directory to: "C:\path"

Processing script file: "C:\path\test.nsi" (ACP)
!include: "C:\Program Files (x86)\NSIS\Include\nsDialogs.nsh" (UTF8)
!include: closed: "C:\Program Files (x86)\NSIS\Include\nsDialogs.nsh"
Page: custom (creator:MyPageCreate)
Page: InstFiles
Function: "MyPageCreate"
File: "nsDialogs.dll"->"$PLUGINSDIR\nsDialogs.dll" [compress] 4682/9728 bytes
Plugin command: Create 1018
Pop: $0
Plugin command: CreateControl STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 0 0 100% 40u You are not supposed to perform download/file operations on a page...
Pop: $0
Plugin command: Show
File: "NSISdl.dll"->"$PLUGINSDIR\NSISdl.dll" [compress] 9083/15360 bytes
Plugin command: download http://web.archive.org/web/2000/http://www.rfc-editor.org/rfc/rfc20.txt $pluginsdir\nsisdl.txt
Pop: $0
Plugin directories:
C:\Program Files (x86)\NSIS\Plugins\x86-unicode
Plugin not found, cannot call inetc::get
Error in script "C:\path\test.nsi" on line 17 -- aborting creation process
Anders#
It tells you what the error is right there, you don't have the inetc plug-in. Comment out the inetc line and the pop after (but it would be better if you just download the plug-in).
CharlesH#
Thanks Anders. It was the https server. Even if I use a http URL it has the same problem. The inetc::get command works. I suspect the file was not "disappearing". Rather, an empty file was being created and then destroyed. The test file I was downloading was an empty text file so I didn't realise.

Now I just have to figure out how to download different files based on what button is pressed, and then execute them. And do it in a section rather than a page. My code currently has 3 sections:
-MainProgram
-Icons_Reg
Section Uninstall

These were all copied from an online example.

I get how to get pages to appear in the right order - it's just the order they are coded in. All the section code currently comes after all of the page code. I am not sure whether to use an existing section, add a new one and where, and how to get it to respond to a button press. There could be a situation where a user wants to press two buttons, in which case I would prefer to keep the page static and respond to each button as it is pressed. Do you know if there are similar examples anywhere?
Anders#
You would normally use a component page if you want to give the user the option to choose something. Each Section with a name gets a checkbox on the Components page.

If you absolutely want to use a custom page with either checkboxes or buttons, store the results in some variables and check the variables in a section later.
CharlesH#
Hi Anders, I am still plugging away at this one. I have encountered a minor problem: inetc::get does not like multiple dots (periods) in the destination file name. Simple workaround is to change the file name, but I would prefer to stick with the same file name as it is a file from another vendor and I don't want to make any changes to it. Is there some other fix for this?
CharlesH#
Also, is it possible to download files to the default windows Downloads folder? I can only figure out how to download to $INSTDIR.
CharlesH#
I think I answered the second question. Will this be robust?

Var downloadsPath
Var buttonOut
Function MyCustomPage2
System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"
StrCpy $downloadsPath "C:\Users\$0\Downloads"
${NSD_CreateButton} 0 80u 100% 15u "Download fie."
Pop $buttonOut
${NSD_OnClick} $buttonOut button_click
FunctionEnd


Function button_click
inetc::get "https://www.website.com/path/file.ext" "$downloadsPath\file.ext" /END
FunctionEnd
Anders#
!include WinCore.nsh
var downloadsPath
Section
GetKnownFolderPath $downloadsPath ${FOLDERID_Downloads}
StrCmp $downloadsPath "" 0 +2
StrCpy $downloadsPath "$PROFILE\Downloads" ; Fallback directory (< Vista)
MessageBox MB_OK $downloadsPath
SectionEnd 
You are missing a Pop after inetc::get
CharlesH#
Thanks Anders, that looks like a more reliable way to get it.

I added a "Pop $0" line after each call to inetc::get. Not sure what it does. It doesn't seem to make any difference.

Any tips on how to allow downloaded files with multiple dots in the file name?