51Testing软件测试论坛

标题: QTP11 续期Licence VBS脚本 [打印本页]

作者: wuxue107    时间: 2013-7-9 11:21
标题: QTP11 续期Licence VBS脚本
总是见有人在论坛问QTP11重置续期的问题。每个月都要重置一次挺麻烦。写个VBS减少劳动力


  1. If LCase(Right(WScript.FullName,11)) = "wscript.exe" Then
  2.         CreateObject("Wscript.Shell").Run "CScript "&Chr(34)&WScript.ScriptFullName&Chr(34)
  3.         WScript.quit
  4. End If
  5. On Error Resume Next
  6. Set SreamOut = WScript.StdOut
  7. Set SreamIn = WScript.StdIn
  8. Set oShell = CreateObject("Wscript.Shell")

  9. SreamOut.WriteLine ""
  10. SreamOut.WriteLine "    ##############################################"
  11. SreamOut.WriteLine "    ########   QTP11版本使用延时工具    ##########"
  12. SreamOut.WriteLine "    ##############################################"
  13. SreamOut.WriteLine ""

  14. envOK = True

  15. Err.clear
  16. profilePath = oShell.Environment("Process")("ALLUSERSPROFILE")
  17. If Err Then
  18.         SreamOut.WriteLine "找不到环境变量 ""ALLUSERSPROFILE""!"
  19.         envOK = False
  20. else
  21.         OS = oShell.Exec("cmd /c ver").StdOut.ReadAll
  22.         if instr(OS,"6.1") then
  23.         'Win7
  24.                 configPath = profilePath & "\SafeNet Sentinel"
  25.         elseif instr(OS,"6.0") then
  26.         'Vista
  27.                 configPath = profilePath & "\SafeNet Sentinel"
  28.         elseif instr(OS,"5.2") then
  29.         '2003
  30.                 configPath = profilePath & "\Application Data\SafeNet Sentinel"
  31.         elseif instr(OS,"5.1") then
  32.         'XP
  33.                 configPath = profilePath & "\Application Data\SafeNet Sentinel"
  34.         else
  35.                 configPath = profilePath & "\SafeNet Sentinel"
  36.         end If
  37.         If not CreateObject("scripting.filesystemobject").folderExists(configPath) Then
  38.                 configPath = "没有找到QTP的使用许可证目录!"
  39.                 envOK = false
  40.         End if
  41. End If

  42. SreamOut.WriteLine " 使用许可证目录:" & configPath

  43. Err.clear
  44. installPath = oShell.RegRead("HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\Environment\Icons\")
  45. If Err Then
  46.         binPath = "没有找到QTP的安装目录!"
  47.         envOK = false
  48. End If
  49. binPath = Left(installPath,InStrRev(installPath,"\")-1)
  50. SreamOut.WriteLine " QTP的Bin目录为:" & binPath

  51. SreamOut.WriteLine ""
  52. If not envOK Then
  53.          SreamOut.WriteLine " QTP重置试用许可证失败!"
  54.          WScript.StdIn.ReadLine
  55.          Wscript.quit
  56. End If

  57. SreamOut.WriteLine " 删除目录: ""SafeNet Sentinel"""
  58. oShell.Run "cmd /c rmdir /q /s """ & configPath & """",0
  59. wscript.sleep 1500
  60. SreamOut.WriteLine " 执行文件: instdemo.exe"
  61. oShell.Run "cmd /c """ & binPath & "\instdemo.exe""",0
  62. SreamOut.WriteLine ""
  63. SreamOut.WriteLine ""
  64. SreamOut.WriteLine " QTP重置试用许可证成功!"
  65. WScript.StdIn.ReadLine

复制代码

作者: maplee    时间: 2013-7-9 11:46
这。。貌似违反版规了啊,
趁版主没发现,赶紧copy下来




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2