Inno setup 在inno安装程序中作为后期安装运行netsh.exe

Inno setup 在inno安装程序中作为后期安装运行netsh.exe,inno-setup,acl,netsh,Inno Setup,Acl,Netsh,在下面的脚本中,我运行netsh.exe在TCP端口上启用http(GET请求)。但是,即使安装日志显示退出代码为0,并且参数是正确的。我没有看到端口已启用。有什么想法吗 ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Netsh" #define MyAp

在下面的脚本中,我运行netsh.exe在TCP端口上启用http(GET请求)。但是,即使安装日志显示退出代码为0,并且参数是正确的。我没有看到端口已启用。有什么想法吗

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Netsh"
#define MyAppVersion "1.0"
#define MyAppPublisher "Draper Laboratory"
#define MyAppURL "http://www.draper.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{112CF442-ACA5-4799-BC72-72C98F90CED1}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
CreateAppDir=no
OutputDir=C:\Users\ysg4206\Desktop
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
ChangesEnvironment=True
SetupLogging=True

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Run]
Filename: "{sys}\netsh.exe"; Parameters: "http delete urlacl url=http://*:4326/"; WorkingDir: "{sys}"; Flags: postinstall runascurrentuser; Description: "Remove Web Port 4326"
Filename: "{sys}\netsh.exe"; Parameters: "http add urlacl url=http://*:4326/ user={%USERDOMAIN}\{%USERNAME}"; WorkingDir: "{sys}"; Flags: postinstall runascurrentuser; Description: "Add Web Port 4326"
下面是日志:

2012-12-24 14:02:43.123   Log opened. (Time zone: UTC-05:00)
2012-12-24 14:02:43.123   Setup version: Inno Setup version 5.5.2 (a)
2012-12-24 14:02:43.123   Original Setup EXE: C:\Users\ysg4206\Desktop\setup.exe
2012-12-24 14:02:43.123   Setup command line: /SL5="$4A0C72,54272,54272,C:\Users\ysg4206\Desktop\setup.exe" /SPAWNWND=$EF1420 /NOTIFYWND=$3540C26 /log="setup.log"
2012-12-24 14:02:43.124   Windows version: 6.1.7601 SP1  (NT platform: Yes)
2012-12-24 14:02:43.124   64-bit Windows: Yes
2012-12-24 14:02:43.124   Processor architecture: x64
2012-12-24 14:02:43.124   User privileges: Administrative
2012-12-24 14:02:43.124   64-bit install mode: No
2012-12-24 14:02:43.128   Created temporary directory: C:\Users\ysg4206\AppData\Local\Temp\is-JCDBN.tmp
2012-12-24 14:02:45.492   Starting the installation process.
2012-12-24 14:02:45.495   Directory for uninstall files: C:\Windows
2012-12-24 14:02:45.496   Will append to existing uninstall log: C:\Windows\unins000.dat
2012-12-24 14:02:45.500   -- File entry --
2012-12-24 14:02:45.501   Dest filename: C:\Windows\unins000.exe
2012-12-24 14:02:45.504   Time stamp of our file: 2012-12-24 14:02:42.959
2012-12-24 14:02:45.504   Dest file exists.
2012-12-24 14:02:45.504   Time stamp of existing file: 2012-12-24 14:02:22.794
2012-12-24 14:02:45.505   Version of our file: 51.52.0.0
2012-12-24 14:02:45.506   Version of existing file: 51.52.0.0
2012-12-24 14:02:45.506   Installing the file.
2012-12-24 14:02:45.511   Uninstaller requires administrator: Yes
2012-12-24 14:02:45.608   Leaving temporary file in place for now.
2012-12-24 14:02:45.669   Installation process succeeded.
2012-12-24 14:02:45.832   Need to restart Windows? No
2012-12-24 14:02:46.661   -- Run entry --
2012-12-24 14:02:46.661   Run as: Current user
2012-12-24 14:02:46.661   Type: Exec
2012-12-24 14:02:46.661   Filename: C:\Windows\system32\netsh.exe
2012-12-24 14:02:46.661   Parameters: http delete urlacl url=http://*:4326/
2012-12-24 14:02:46.831   Process exit code: 0
2012-12-24 14:02:46.831   -- Run entry --
2012-12-24 14:02:46.831   Run as: Current user
2012-12-24 14:02:46.831   Type: Exec
2012-12-24 14:02:46.831   Filename: C:\Windows\system32\netsh.exe
2012-12-24 14:02:46.831   Parameters: http add urlacl url=http://*:4326/ user=CSDL-SERVICES\ysg4206
2012-12-24 14:02:46.951   Process exit code: 0
2012-12-24 14:02:46.953   Deinitializing Setup.
2012-12-24 14:02:46.959   Log closed.

进一步的测试表明它正在工作。但我希望有一种暂停cmd.exe框的方法,它会闪烁,显示一些文本,然后退出。我真的看不出信息是什么

我也遇到了类似的问题,但当我试图像最初的问答那样直接运行netsh.exe时,它对我不起作用

我的解决方案是将其作为powershell命令运行。在我的例子中,我没有使用postinstall标志

Filename: "powershell.exe"; \
Parameters: "-NonInteractive -Command netsh http add urlacl url={#MyURL} user='{#MyServiceUser}'"; \
Description: "Add URL registration"; StatusMsg: "Adding URL registration..."; \
Flags: runhidden; Components: MyComponentA;

正如我所解释的,您应该使用API而不是试图调用netsh。您可以通过在该行添加runhidden标志来隐藏闪烁的cmd框。