WMI scripts-stop service

Set objSpoolerSvc =GetObject("WinMgmts:Win32_Service.name='Spooler'")
Set objOutParm = objSpoolerSvc.ExecMethod_("stopService")
If objOutParm.returnValue = 0 Then
WScript.Echo " The Spooler Service has been stopped"
Else
wscript.Echo "Error: " & objOutParm.returnValue
End If

WMI scripts-Put method

'WMI is used for getting information about device,registry etc.Some properties of classes may support "write".this example shows how you can set volume label to C Drive.


Set objSvc=GetObject("WinMgmts:")
Set obj=objSvc.Get("Win32_LogicalDisk.DeviceID='C:'")
obj.VolumeName="System"
obj.Put_

WMI scripts-rename multiple files in a folder

This script can rename multiple files in a specific folder.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'You connect to default namespace with moniker method(winmgmt)

Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\Logs'} Where " _
& "ResultClass = CIM_DataFile")

'it seems little different.It connects two wmi class in one command.uses Win32_Directory class for retrieving folder ,uses CIM_Datafile for files.Associators of usage connects two class like joining two db table.

For Each objFile In colFileList
strNewName = objFile.Drive & objFile.Path & "ABC-" & _
objFile.FileName & "." & objFile.Extension
errResult = objFile.Rename(strNewName)
Next

'this is very simple you assign new file name to strNewName variable.You can add prefix or suffix in here.