VBS Scripting Examples
Revision as of 18:05, 26 July 2008 by PeterHarding (talk | contribs)
Examples
Clear Directory
' ' ClearLoadRunnerDirectory.vbs ' 'Option Explicit Dim fso 'Dim folder ' Dim pcpfolder folder = "C:\lr" ' Set fso = CreateObject("Scripting.FileSystemObject") 'If fso.FolderExists( folder ) Then ' fso.DeleteFolder folder 'End If fso.DeleteFolder folder, true 'Wscript.Echo strProcesses WScript.Quit
' ' CurrentProcesses.vbs ' ' As of April 2008, more information about scripting WMI is available at: ' http://www.microsoft.com/technet/scriptcenter/guide/sas_wmi_dieu.mspx?mfr=true ' ' The following script was modified from one found at: ' http://bucarotechelp.com/computers/winadmin/94051303.asp ' Option Explicit Dim objWMIService Dim colProcesses, objprocess, strProcesses Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcesses = objWMIService.InstancesOf("Win32_Process") strProcesses = "" strProcesses = "Processes: " & colProcesses.Count & vbCrLf & vbCrLf For Each objProcess In colProcesses ' strProcesses = strProcesses & objProcess.Name & vbTab & "(" & objProcess.ProcessID & ")" & vbCrLf strProcesses = strProcesses & objProcess.Name & vbCrLf Next 'for i = UBound(myArray) - 1 To 0 Step -1 ' for j = 0 to i ' if myArray(j) > myArray(j+1) then ' temp = myArray(j+1) ' myArray(j+1) = myArray(j) ' myArray(j) = temp ' end if ' next 'next Wscript.Echo strProcesses WScript.Quit