最新消息:

有关SimpleSC插件的实例

nsis 永恒心锁 2969浏览 0评论
!include MUI2.nsh
!include LogicLib.nsh
!include nsDialogs.nsh
Name "NetHalt"
OutFile "nhclient.exe"
InstallDir $PROGRAMFILESNetHalt
InstallDirRegKey HKLM "SOFTWARENetHalt" "InstallDir"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "COPYING"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function .onInit
 nsisos::osversion
 ${If} $0 < 5
 MessageBox MB_OK "Windows 2000 (NT 5.0) or greater is required"
 Abort
 ${EndIf}
FunctionEnd
# Do local install
#
Section "NetHalt"
 SetShellVarContext all
 SetOutPath $INSTDIR
 # Stop all running nhtray.exe processes
 #
 StrCpy $0 "nhtray.exe"
 KillProc::KillProcesses
 # Check if the NetHalt service is installed
 #
 SimpleSC::ExistsService "nhclient"
 Pop $0
 # Stop+Remove the NetHalt service if it's installed
 #
 ${If} $0 == 0
 DetailPrint "Stopping NetHalt Client service..."
 SimpleSC::StopService "nhclient"
 DetailPrint "Removing NetHalt Client service..."
 SimpleSC::RemoveService "nhclient"
 ${EndIf}
 WriteRegStr HKLM "SOFTWARENetHalt" "InstallDir" $INSTDIR
 cinst::reg_write "dword" "SOFTWARENetHalt" "use_server" "0"
 cinst::reg_write "string" "SOFTWARENetHalt" "server_name" ""
 cinst::reg_write "dword" "SOFTWARENetHalt" "server_port" "0"
 cinst::reg_write "dword" "SOFTWARENetHalt" "server_refresh" "1800"
 cinst::reg_write "dword" "SOFTWARENetHalt" "warning" "300"
 cinst::reg_write "dword" "SOFTWARENetHalt" "abort" "0"
 cinst::reg_write "dword" "SOFTWARENetHalt" "delay" "0"
 cinst::reg_write "string" "SOFTWARENetHalt" "sdtimes" ""
 WriteUninstaller "$INSTDIRuninstall.exe"
 File "srcnhclient.exe"
 File "srcevlog.dll"
 File "srcnhtray.exe"
 File "srcnhconfig.exe"
 # Add the event log source (evlog.dll) to the registry
 #
 WriteRegStr HKLM "SYSTEMCurrentControlSetServicesEventlogApplicationNetHalt Client" "EventMessageFile" "$INSTDIRevlog.dll"
 WriteRegDWORD HKLM "SYSTEMCurrentControlSetServicesEventlogApplicationNetHalt Client" "TypesSupported" 0x00000007
 # Add the uninstaller to Add/Remove programs
 #
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstallNetHalt" "DisplayName" "NetHalt"
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstallNetHalt" "UninstallString" "$INSTDIRuninstall.exe"
 WriteRegDWORD HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstallNetHalt" "NoModify" 1
 WriteRegDWORD HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstallNetHalt" "NoRepair" 1
 # Install and start the NetHalt service
 # TODO: Check for errors
 #
 DetailPrint "Installing NetHalt Client service..."
 SimpleSC::InstallService "nhclient" "NetHalt Client" "16" "2" "$INSTDIRnhclient.exe" "" "" ""
 DetailPrint "Starting NetHalt Client service..."
 SimpleSC::StartService "nhclient"
 # Add nhtray.exe to the registry to run at login
 #
 WriteRegStr HKLM "SOFTWAREMicrosoftWindowsCurrentVersionRun" "NetHalt" "$INSTDIRnhtray.exe"
 # Launch nhtray.exe
 #
 Exec '"$INSTDIRnhtray.exe"'
 # Create shortcuts
 #
 CreateDirectory "$SMPROGRAMSNetHalt"
 CreateShortCut "$SMPROGRAMSNetHaltTray Icon.lnk" "$INSTDIRnhtray.exe"
 CreateShortCut "$SMPROGRAMSNetHaltConfiguration.lnk" "$INSTDIRnhconfig.exe"
 CreateShortCut "$SMPROGRAMSNetHaltUninstall.lnk" "$INSTDIRuninstall.exe"
SectionEnd
Function un.onInit
 SetShellVarContext all
 ReadRegStr $INSTDIR HKLM "SOFTWARENetHalt" "InstallDir"
 MessageBox MB_YESNO "This will uninstall NetHalt, continue?" IDYES NoAbort
 Abort
 NoAbort:
FunctionEnd
Section "Uninstall"
 # Stop and remove the NetHalt service
 #
 DetailPrint "Stopping NetHalt Client service..."
 SimpleSC::StopService "nhclient"
 DetailPrint "Removing NetHalt Client service..."
 SimpleSC::RemoveService "nhclient"
 # Stop all running nhtray.exe processes
 #
 StrCpy $0 "nhtray.exe"
 KillProc::KillProcesses
 # Delete shortcuts
 #
 Delete "$SMPROGRAMSNetHaltTray Icon.lnk"
 Delete "$SMPROGRAMSNetHaltConfiguration.lnk"
 Delete "$SMPROGRAMSNetHaltUn-Install.lnk"
 Delete "$SMPROGRAMSNetHalt"
 DeleteRegValue HKLM "SOFTWAREMicrosoftWindowsCurrentVersionRun" "NetHalt"
 DeleteRegKey HKLM "SYSTEMCurrentControlSetServicesEventlogApplicationNetHalt Client"
 DeleteRegKey HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstallNetHalt"
 Delete "$INSTDIRnhclient.exe"
 Delete "$INSTDIRevlog.dll"
 Delete "$INSTDIRnhtray.exe"
 Delete "$INSTDIRuninstall.exe"
 RMDir $INSTDIR
SectionEnd
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 有关SimpleSC插件的实例

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址