-1

我正在尝试从 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
4

3 回答 3

2

我不知道您调用的 InternetExplorerAuto_OpenURL 函数是什么。我使用NSISDL

NSISdl::download "http://www.URL.com/file.exe" "C:\temp\file.exe"
于 2013-07-02T06:21:29.353 回答
1

使用NSISdl 插件

NSISdl::download "http://example.com/example.exe" "$Desktop\Your_Folder\example.exe"

于 2013-07-02T10:58:34.587 回答
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"
    

    在您发布的代码中,您似乎只有 url 部分

  • 快捷方式的扩展名是.lnk,因此不应.exe调用CreateShortcut

    CreateShortCut "$Desktop\NIS Edit\File.lnk" "$INSTDIR\File.exe"
    

    在桌面的子目录中创建快捷方式似乎很奇怪。或者,也许您想在$PROGRAMFILES目录中创建一个快捷方式,以便将其放在子目录中?

于 2013-07-03T10:49:52.490 回答