日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

VBS 学习

發布時間:2024/4/17 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VBS 学习 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

VBS其他功能

  • 獲取系統用戶名

    DimWshNetwork

    Set WshNetwork =CreateObject("WScript.Network")

    strTaccount = WshNetwork.UserName

    strRoot = "D:\"&strTaccount&"\Desktop\QAAutomation"

  • 獲取系統時間

    year(Now)& Month(Now) & day(Now) & Hour(Now) & Minute(Now) & Second(Now)

    randomize()

    dim Random:Random=int(rnd*999+1)

  • Split ,Ubound,For each

    Dim MyStrs
    MyStrs=split("a,b,c,d",",")
    msgbox ubound(MyStrs)

    For each Strs In MyStrs

    Print Strs

    Next

    返回一個下標從0到ubound(MyStrs)的數組,數組元素共ubound(a)+1個

  • 啟動應用程序

    a.

    SetStartURL ="https://agent.monthly.qa.motoristsinsurance.com/home/"

    Set IE =CreateObject("InternetExplorer.Application")

    IE.Visible= true

    IE.NavigateStartURL????

    b.

    Dim IE,Chrome, strURL

    IE ="C:\Program Files\Internet Explorer\iexplore.exe"

    Chrome ="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

    strURL ="https://agent.monthly.qa.motoristsinsurance.com/home/"

    'SystemUtil.Run? IE ,strURL ,,,3

    SystemUtil.Run? Chrome ,strURL ,,,3

  • ?

  • 關閉后臺進程

    On ErrorResume Next

    ? ?Set objWMIService =GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

    ?? Set arrProcesses =objWMIService.ExecQuery( "select * from win32_process where Name='"&strProcName&"'" )

    ? ?For Each proccess In arrProcesses

    ? ?proccess.Terminate 0

    Next

  • 獲取系統時間?

    CurrentTime = year(Now)&"-"&Month(Now)&"-"&day(Now)&"-"&Hour(Now)&":"&Minute(Now)&":"&Second(Now)

  • 后臺啟動UFT跑vbs腳本

    'Create QTP object

    Set QTP = CreateObject("QuickTest.Application")

    QTP.Launch

    QTP.Visible = TRUE

    'Open QTP Test

    QTP.Open "\\MGPCTFSW01\UserFolders$\t165050\Desktop\Portal_Smoke_1214\Portal_MainScript", TRUE

    'Set Result location

    Set qtpResultsOpt = CreateObject("QuickTest.RunResultsOptions")

    qtpResultsOpt.ResultsLocation = "\\MGPCTFSW01\UserFolders$\t165050\Desktop\Portal_Smoke_1214\Result"

    'Run QTP test

    QTP.Test.Run qtpResultsOpt

    'Close QTP

    QTP.Test.Close

    QTP.Quit

    ?

    ' batch run vbs: CScript "\\MGPCTFSW01\UserFolders$\t165050\Desktop\QTP.vbs"

  • Others

    去掉字符串前面和后面的空格 Trim()

    從字符串中返回指定數目的字符 Mid(string, start[, length])

    從字符串右邊返回指定數目的字符 Right(string, length)

    返回指定數目的從字符串左邊算起的字符 Left(string, length)

    把變量b轉換為字符串 a=CStr(b)

    將一個字符串中的小寫字母轉化為大寫字母 Ucase()

    返回一個字符串在另一個字符串中首次出現的位置 InStr()

  • Load function

    ?LoadFunctionLibrary "\\MGPCTFSW01\UserFolders$\"&UserAccount&"\Desktop\Portal_Smoke_1214\Functions\Functions.qfl"

    ?

  • 鍵盤輸入

    ?

  • ?

    ???????? Dim wshshell

    ????? ?? Set wshshell=createobject("wscript.shell")

    ??? ???? wshshell.sendkeys"{ENTER}"

    ??

    ?

    ?

    轉載于:https://www.cnblogs.com/AmyHu/p/9168429.html

    總結

    以上是生活随笔為你收集整理的VBS 学习的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。