• Rcmd.vbs [remote CMD with WMI] remote script


    Copy codeThe code is as follows: On Error Resume Next Set outstreem=Wscript.stdout If (LCase(Right(Wscript.fullname,11))=”Wscript.exe”) Then Set objShell=Wscript.CreateObject(“Wscript.shell”) objShell.Run(“cmd.exe /k cscript //nologo “&Chr(34)&Wscript.ScriptFullName&Chr(34)) Wscript.Quit End If If Wscript.arguments.Count<4 Then usage() Wscript.echo “Not enough Parameters.” Wscript.Quit End If ip=Wscript.arguments(0) username=Wscript.arguments(1) password=Wscript.arguments(2) CmdStr=Wscript.arguments(3) EchoStr=Wscript.arguments(4) foldername=”c:\\windows\\temp\\” wsh.echo “Conneting “&ip&” ….” Set objlocator=CreateObject(“wbemscripting.swbemlocator”) Set objswbemservices=objlocator.connectserver(ip,”root/cimv2″,username,password) showerror(err.number) Set Win_Process=objswbemservices.Get(“Win32_ProcessStartup”) Set Hide_Windows=Win_Process.SpawnInstance_ […]

  • WMI script master incomplete manual


    Windows management instrumentation is a core Windows Management Technology; users can use WMI to manage local and remote computers. WMI provides a continuous and consistent way for daily management through programming and scripting languages. Users can:1. Start a process on the remote computing machine.2. Set a process to run on a specific date and time.3. […]

  • VBS calls WMI to search hard disk MP3 files


    Copy codeThe code is as follows: strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” _ & strComputer & “\root\cimv2”) Set colFiles = objWMIService. _ ExecQuery(“Select * from CIM_DataFile where Extension = ‘mp3′”) For Each objFile in colFiles Wscript.Echo objFile.Name Next Top upExecQuery(“Select * from CIM_DataFile where Extension = ‘mp3′”) Replace the MP3 in […]

  • Code for VBS to get CPU utilization through WMI


    Python is powerful, but it still uses VBS to call WMI. Copy codeThe code is as follows: On Error Resume Next strComputer = “.” Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”) Set colItems = objWMIService.ExecQuery(“Select * from Win32_Processor”,,48) For Each objItem in colItems WScript.Echo “LoadPercentage: ” & objItem.LoadPercentage Next Reference link:Win32_Processor Class Original: http://demon.tw/programming/vbs-wmi-cpu-usage.html

  • WMI stdregprov implements code (local or remote) through VBScript of WMI operation registry


    Because of its length, only the code for the function itself is shown on this page. The demo script that shows how to use this function is available as a separate download. Copy codeThe code is as follows: Function ReadRegValue( myComputer, myRegPath, myRegValue ) ‘ This function reads a value from the registry of any […]

  • WMI’s Implementation Code for Creating System Services


    Copy codeThe code is as follows: Const OWN_PROCESS = &H10Const ERR_CONTROL = &H2Const INTERACTIVE = False ServiceName = “TestService”DisplayName = “This is a test service.”InstallPath = “c:\windows\system32\Test.exe” Set ObjWMI = GetObject(“winmgmts:” & “{impersonationLevel=impersonate, (Security)}!\\.\root\cimv2”) Set ObjSvr = ObjWMI.Get(“Win32_Service”)Return = ObjSvr.Create(ServiceName, DisplayName, InstallPath, OWN_PROCESS, ERR_CONTROL, “Automatic”, INTERACTIVE, “LocalSystem”, “”)If (Return = 0) Then Wscript.Echo “Service create success.” Wscript.Echo […]

  • Vbs modifies NTFS permissions of file folders through WMI


    Use WMI to modify NTFS permissions for file folders, code: Copy codeThe code is as follows: strUser = “guests”strPath = “D:\\abc.txt”RetVal = AddPermission(strUser,strPath,”R”,True) ‘————————————————————————- ‘Used to add a permission setting to files and folders. Return value: 0-successful, 1-account does not exist, 2-path does not exist‘strUser’denotes a username or group name‘strPath represents folder path or file […]

  • Visual Basic Calls WMI to Search Hard Disk Files and Count


    A VBS written many years ago called WMI to traverse the search hard disk files and count the functions. Today, I sort out the disk, see, send it up. Core code: Function wmisfile(path_sf,justcnt) ‘On Error Resume Next StrComputer = “.” Set ObjWMIService = GetObject(“winmgmts:\\” & StrComputer & “\root\cimv2”) Set FileList = objWMIService.ExecQuery _ (“ASSOCIATORS OF […]