Login   /   Register

Get all processing on the local machine

April 11th, 2008 by Yaron Assa
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

Get all running processing on the local machine:

Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
 
strComputer = “.”
 
Set objWMIService = GetObject(”winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2″)
 
Set colProcess = objWMIService.ExecQuery _
(”Select * from Win32_Process”)
 
For Each objProcess in colProcess
strList = strList & vbCrLf & _
objProcess.Name
Next
 
Print strList

Determine the name of the time zone in which a computer is running

April 1st, 2008 by daniva
     1 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 5
Loading ... Loading ...

Use the Win32_TimeZone class and check the value of the Description property.

Convert WMI dates to standard dates and times

April 1st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

To convert WMI dates to FILETIME or VT_DATE format or to parse the date into component year, month, day, hours, and so on, you must write your own code.

Determine if a Folder Has Any Files with a Specific File Extension

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

All we have to do is write a WMI query that includes the path of the folder we want to check as well as the file extension we’re checking for. For example, this script retrieves a collection of all the .bak files found in the C:\Logs folder:

Get a List of All DLL files in a Folder

March 31st, 2008 by daniva
     1 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 5
Loading ... Loading ...

the immediately solution is by using a WMI script. Admittedly, we could have achieved the same results by using the FileSystemObject.
We opted to go with WMI for one simple reason: that enables us to run this script against remote computers.

Rename all files in a folder

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

Sometimes we need to rename all the files in a given folder, either by appending the date, changing the file extension.
The following example simulates a backup operation, by renaming all files extensions in the LOG folder from .log to .bak.
The Script assumes that you already have a folder under location C:\LOG and assumes that the folder contains at least 1 xxxx.log file.