杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1614|回复: 0

NSIS一键安装网络打印机

[复制链接]
发表于 2019-3-1 17:08:05 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
为了方便安装打印机,所以特地写了这个脚本。希望对大家有所帮助。
在窗体中创建Droplist,并且读取选择值,来进行后续操作。
点击安装来触发
  1. function OnClickinstall
  2. SetShellVarContext all
  3. ${NSD_GetText} $DropList1 $stext

  4. ${if} $stext == "20楼打印机"
  5. ;===打印机IP地址===
  6. StrCpy $ipadd '192.168.1.42'
  7. ;===打印机名称===
  8. StrCpy $pname 'KONICA MINOLTA 500/420/360VXL'
  9. ;===驱动程序总文件===
  10. StrCpy $local "\\172.16.0.5\Software\驱动程序\20楼新打印机驱动\20楼打印机32位驱动\KOBZOJB_.inf"
  11. ${andIf} ${RunningX64}
  12. push $local
  13. StrCpy $local "\\172.16.0.5\Software\驱动程序\20楼新打印机驱动\20楼打印机64位驱动\KOBZOJB_.inf"
  14. ${endif}

  15. ${if} $stext == '19楼打印机'
  16. ;===打印机IP地址===
  17. StrCpy $ipadd '192.168.8.41'
  18. ;===打印机名称===
  19. StrCpy $pname 'HP Universal Printing PCL 6'
  20. ;===驱动位置===
  21. StrCpy $local "\\172.16.0.5\Software\驱动程序\19楼新打印机驱动\HP Universal Print Driver\pcl6-x32\hpcu175u.inf"
  22. ;===驱动程序总文件===
  23. ${andIf} ${RunningX64}
  24. push $local
  25. StrCpy $local "\\172.16.0.5\Software\驱动程序\19楼新打印机驱动\HP Universal Print Driver\pcl6-x64\hpcu175u.inf"
  26. ${endif}

  27. ${if} $stext == '38楼打印机'
  28. ;===打印机IP地址===
  29. StrCpy $ipadd '192.168.10.39'
  30. ;===打印机名称===
  31. StrCpy $pname 'KONICA MINOLTA 501/421/361PCL'
  32. ;===驱动位置===
  33. StrCpy $local "\\192.168.10.10\驱动程序\打印机驱动\打印机安装文件\PCL_Win7_32\Win_x86\KOBZEJ__.inf"
  34. ;===驱动程序总文件===
  35. ${andIf} ${RunningX64}
  36. push $local
  37. StrCpy $local "\\192.168.10.10\驱动程序\打印机驱动\打印机安装文件\PCL_Win7_64\Win_x64\KOBZEJ__.inf"
  38. ${endif}

  39. ;===添加打印机端口===
  40. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports' "StatusUpdateInterval" "0000000a"
  41. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports' "StatusUpdateEnabled" "00000001"
  42. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports' "LprAckTimeout" "000000b4"

  43. ;===添加具体端口===
  44. MessageBox MB_ICONINFORMATION|MB_OK '你选择安装的打印机为$stext $\n$\r 该打印机IP地址为$ipadd $\n$\r 驱动程序位置为:$local'
  45. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "Protocol" "00000001"
  46. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "Version" "00000002"
  47. WriteRegStr HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "HostName" $ipadd
  48. WriteRegStr HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "IPAddress" ""
  49. WriteRegStr HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "HWAddress" ""
  50. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "PortNumber" "9100"
  51. WriteRegStr HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "SNMP Community" "public"
  52. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "SNMP Enabled" "00000000"
  53. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "SNMP Index" "00000001"
  54. WriteRegDWORD HKLM 'SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\$ipadd' "PortMonMibPortIndex" "00000000"


  55. ;===重启打印机安装服务===
  56. nsExec::Exec 'net stop spooler'
  57. nsExec::Exec 'net start spooler'

  58. ;===调用系统组件安装打印机===
  59. ExecWait 'rundll32 printui.dll,PrintUIEntry /if /b "$pname" /r $ipadd /m "$pname" /z /f "$local" '
  60. ExecWait 'rundll32 printui.dll,PrintUIEntry /y /n "$pname" /q'
  61. MessageBox MB_ICONINFORMATION|MB_OK '安装成功,如有问题,请和本人联系'

  62. FunctionEnd
复制代码




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-17 23:03 , Processed in 0.103718 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表