Boosting myself to HIGH process priority
Context: Windows Server 2008R2, VBScript
The script gets its own name, then looks through the Win32_Processes for a match with CSCRIPT.EXE and a CommandLine containing that name. Any matches (should be only one, but could be more) are boosted to HIGH process priority.
option explicit dim sName dim sComputer dim oWMI dim cProcesses dim oProcess CONST HIGH = 256 sComputer = "." Set oWMI = GetObject("winmgmts:\\" & sComputer & "\root\cimv2") sName = Wscript.ScriptName Set cProcesses = oWMI.ExecQuery("Select * from Win32_Process Where Name = 'cscript.exe' And CommandLine LIKE '%" & sName & "%'") For Each oProcess in cProcesses oProcess.SetPriority(HIGH) WScript.Echo "Boosted myself" Next
And in JScript
var HIGH = 256 var sComputer = "." var sName = WScript.ScriptName var query = GetObject("winmgmts:\\\\" + sComputer + "\\root\\cimv2").ExecQuery("Select * from Win32_Process Where Name = 'cscript.exe' And CommandLine LIKE '%" + sName + "%'") var cProcesses = new Enumerator(query); // Enumerate WMI objects for ( ; !cProcesses.atEnd(); cProcesses.moveNext()) { var oProcess = cProcesses.item() oProcess.Priority = HIGH WScript.Echo( "Boosted myself") }
Β© Bruce M. Axtens, 2013.












