I am trying to download an .exe from a URL and have it go a folder that I want it to, not the download folder. This is what I have so far in the code:
Section "file" SEC07
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
push "http://www.URL.com/file.exe"
call InternetExplorerAuto_OpenURL
SectionEnd
At this point it opens the download folder and askes if you want to run it. How do I make it so that it saves the .exe to a folder I make on the desktop??? Please Help!!
Edit: Thank you for the help guys, but it will not make a short cut for the exe in the file I tell it to. It keeps making a doc called E. Am I doing something wrong or am I missing a line of code in there. This is what I have.
Section "CleanWDF" SEC09
SetOutPath "$INSTDIR\cleanWDF.exe"
SetOverwrite ifnewer
NSISdl::download_quiet "download.File.com/File.exe";
CreateShortCut "$Desktop\NIS Edit\File.exe" "$INSTDIR\File.exe"
SectionEnd
Edit 2:
Here is the script that I am trying to get working. If you could please tell me where I am going wrong.
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Support tool"
!define PRODUCT_VERSION "3.0"
!define PRODUCT_PUBLISHER "Me"
!define PRODUCT_WEB_SITE "https://www.mywebsite.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\AppPaths\C:\Users\sgould\Desktop\NIS Edit"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
; MUI 1.67 compatible ------
!include "MUI2.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\C:\Users\"user"\Desktop\NIS Edit"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
!define VARIANT_TRUE -1 ;((VARIANT_BOOL)-1)
!define VT_ERROR 10
!define DISP_E_PARAMNOTFOUND 0x80020004
!define CLSCTX_LOCAL_SERVER 0x4
!define CLSID_InternetExplorer {0002DF01-0000-0000-C000-000000000046}
!define IID_IWebBrowserApp {0002DF05-0000-0000-C000-000000000046}
!define IWebBrowserApp.Navigate ->11(i,i,i,i,i)i
!define IWebBrowserApp.put_Visible ->41(&i2)i
Function InternetExplorerAuto_OpenURL
exch $2
push $0
push $1
System::Call "ole32::CoCreateInstance( \
g '${CLSID_InternetExplorer}', i 0, \
i ${CLSCTX_LOCAL_SERVER}, \
g '${IID_IWebBrowserApp}', *i 0 r0)"
System::Call "$0${IWebBrowserApp.put_Visible} (${VARIANT_TRUE}).r1"
System::Call "*(i ${VT_ERROR},i ${DISP_E_PARAMNOTFOUND},i)i.r1" ;VARIANT
System::Call 'Oleaut32::SysAllocString(w "$2")i.r2'
System::Call "$0${IWebBrowserApp.Navigate} ($2,$1,$1,$1,$1)"
System::Free $1
System::Call 'Oleaut32::SysFreeString(ir2)'
System::Call "$0->2()"
pop $1
pop $0
pop $2
FunctionEnd
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "supportTools.exe"
InstallDir "C:\Users\"user"\Desktop\NIS Edit"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Section "file" SEC03
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
push "http:"
CreateShortCut "$Desktop\file.lnk" "$Desktop\NSI Edit\file.exe"
call InternetExplorerAuto_OpenURL
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\C:\Users\sgould\Desktop\NIS Edit\NIS Edit"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\SupportTools.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file-2.30-bin.zip"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$INSTDIR\file.exe"
Delete "$SMPROGRAMS\Support Tools\Uninstall.lnk"
Delete "$SMPROGRAMS\Support Tools\Website.lnk"
RMDir "$INSTDIR"
RMDir ""
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
I don't know what is that InternetExplorerAuto_OpenURL function you're calling. I use NSISDL:
NSISdl::download "http://www.URL.com/file.exe" "C:\temp\file.exe"
Use NSISdl Plugin
NSISdl::download "http://example.com/example.exe" "$Desktop\Your_Folder\example.exe"
There are several issues:
SetOutPath
is for setting the directory wher you want to put some files, it is not the path of a single file.the syntax for calling NSISdl::download_quiet
is
NSISdl::download_quiet url_of_the_file_to_get name_of_the_local_file
in your case, something like
SetOutPath "$INSTDIR"
NSISdl::download_quiet "download.File.com/File.exe" "$INSTDIR\File.exe"
in the code you posted, you seem to have only the url part
The extension for a shortcut is .lnk
and not .exe
thus the call to CreateShortcut
should be
CreateShortCut "$Desktop\NIS Edit\File.lnk" "$INSTDIR\File.exe"
It seems just weird to create a shortcut in a subdirectory of the desktop. Or maybe that you want to create a shortcut in the $PROGRAMFILES
directory where the usage is to put it in a subdirectory ?
User contributions licensed under CC BY-SA 3.0