用inno setup打包工具打包生成的exe文件没有开机启动设置,我们要修改.iss文件,有两种方式可以实现开机启动。
方法一:
有一种不写注册表的方法,其实就是将快捷方式添加到“启动”文件夹
[Tasks]
Name: "startupicon"; Description: "开机启动"; GroupDescription: "{cm:AdditionalIcons}";
[Icons]
Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
方法二:修改注册表方法 //注册表启动项
[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "testrun"; ValueData: "{app}\{#MyAppExeName}"
其中"{app}{#MyAppExeName}" 中的#MyAppExeName是你的exe程序的名称
下面是我的.iss部分文件
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
[Files]
Source: "E:\socket\scoketprint.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\socket\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\新筛打印"; Filename: "{app}\scoketprint.exe"
Name: "{group}\{cm:ProgramOnTheWeb,新筛打印}"; Filename: "http://www.example.com/"
Name: "{group}\{cm:UninstallProgram,新筛打印}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\新筛打印"; Filename: "{app}\scoketprint.exe"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\新筛打印"; Filename: "{app}\scoketprint.exe"; Tasks: quicklaunchicon
[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "testrun"; ValueData: "{app}\scoketprint.exe"
[Run]
Filename: "{app}\scoketprint.exe"; Description: "{cm:LaunchProgram,新筛打印}"; Flags: nowait postinstall skipifsilent