我正在尝试从URL下载.exe并将其转到我想要的文件夹,而不是下载文件夹。这是我到目前为止在代码中所拥有的:
Section "file" SEC07
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
push "http://www.URL.com/file.exe"
call InternetExplorerAuto_OpenURL
SectionEnd
此时它会打开下载文件夹并询问您是否要运行它。我怎么做它,以便将.exe保存到我在桌面上制作的文件夹???请帮助!!
编辑:感谢您的帮助,但它不会在我告诉它的文件中为exe做一个捷径。它不断创建一个名为E的文档。我做错了什么,或者我错过了一行代码。这就是我所拥有的。
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
编辑2 :
这是我正在努力工作的脚本。如果你能告诉我我哪里出错了。
; 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
答案 0 :(得分:3)
我不知道您正在调用的InternetExplorerAuto_OpenURL函数是什么。我使用NSISDL:
NSISdl::download "http://www.URL.com/file.exe" "C:\temp\file.exe"
答案 1 :(得分:1)
NSISdl::download "http://example.com/example.exe" "$Desktop\Your_Folder\example.exe"
答案 2 :(得分:0)
有几个问题:
SetOutPath
用于设置您想要放置某些文件的目录,它不是单个文件的路径。调用NSISdl::download_quiet
的语法是
NSISdl::download_quiet url_of_the_file_to_get name_of_the_local_file
在你的情况下,像
SetOutPath "$INSTDIR"
NSISdl::download_quiet "download.File.com/File.exe" "$INSTDIR\File.exe"
在您发布的代码中,您似乎只有网址
快捷方式的扩展名为.lnk
而不是.exe
,因此对CreateShortcut
的调用应为
CreateShortCut "$Desktop\NIS Edit\File.lnk" "$INSTDIR\File.exe"
在桌面的子目录中创建快捷方式似乎很奇怪。或者您可能想在$PROGRAMFILES
目录中创建一个快捷方式,用于将其放在子目录中?