|
总是见有人在论坛问QTP11重置续期的问题。每个月都要重置一次挺麻烦。写个VBS减少劳动力
- If LCase(Right(WScript.FullName,11)) = "wscript.exe" Then
- CreateObject("Wscript.Shell").Run "CScript "&Chr(34)&WScript.ScriptFullName&Chr(34)
- WScript.quit
- End If
- On Error Resume Next
- Set SreamOut = WScript.StdOut
- Set SreamIn = WScript.StdIn
- Set oShell = CreateObject("Wscript.Shell")
- SreamOut.WriteLine ""
- SreamOut.WriteLine " ##############################################"
- SreamOut.WriteLine " ######## QTP11版本使用延时工具 ##########"
- SreamOut.WriteLine " ##############################################"
- SreamOut.WriteLine ""
- envOK = True
- Err.clear
- profilePath = oShell.Environment("Process")("ALLUSERSPROFILE")
- If Err Then
- SreamOut.WriteLine "找不到环境变量 ""ALLUSERSPROFILE""!"
- envOK = False
- else
- OS = oShell.Exec("cmd /c ver").StdOut.ReadAll
- if instr(OS,"6.1") then
- 'Win7
- configPath = profilePath & "\SafeNet Sentinel"
- elseif instr(OS,"6.0") then
- 'Vista
- configPath = profilePath & "\SafeNet Sentinel"
- elseif instr(OS,"5.2") then
- '2003
- configPath = profilePath & "\Application Data\SafeNet Sentinel"
- elseif instr(OS,"5.1") then
- 'XP
- configPath = profilePath & "\Application Data\SafeNet Sentinel"
- else
- configPath = profilePath & "\SafeNet Sentinel"
- end If
- If not CreateObject("scripting.filesystemobject").folderExists(configPath) Then
- configPath = "没有找到QTP的使用许可证目录!"
- envOK = false
- End if
- End If
- SreamOut.WriteLine " 使用许可证目录:" & configPath
- Err.clear
- installPath = oShell.RegRead("HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\Environment\Icons\")
- If Err Then
- binPath = "没有找到QTP的安装目录!"
- envOK = false
- End If
- binPath = Left(installPath,InStrRev(installPath,"\")-1)
- SreamOut.WriteLine " QTP的Bin目录为:" & binPath
- SreamOut.WriteLine ""
- If not envOK Then
- SreamOut.WriteLine " QTP重置试用许可证失败!"
- WScript.StdIn.ReadLine
- Wscript.quit
- End If
- SreamOut.WriteLine " 删除目录: ""SafeNet Sentinel"""
- oShell.Run "cmd /c rmdir /q /s """ & configPath & """",0
- wscript.sleep 1500
- SreamOut.WriteLine " 执行文件: instdemo.exe"
- oShell.Run "cmd /c """ & binPath & "\instdemo.exe""",0
- SreamOut.WriteLine ""
- SreamOut.WriteLine ""
- SreamOut.WriteLine " QTP重置试用许可证成功!"
- WScript.StdIn.ReadLine
复制代码 |
|