Deep Patel: August 2011

Thursday, August 11, 2011

Task Killer!!!

To kill processes in Windows


strComputer = "."

strProcessToKill = InputBox("Task Killer!!! ","Enter process name to kill!")

'strProcessToKill="wmplayer.exe"

'strProcessToKill="excel.exe"


Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")



count = 0

For Each objProcess in colProcess
objProcess.Terminate()
count = count + 1
Next

wscript.echo "Killed " & count & " instances of " & strProcessToKill & "on " & strComputer

Override Windows AutoLock on Computers

Many of us face Autolock on computers. This wscript will keep on executing and will override the Windows Autolock.


'Purpose : Workaround for autolock policy.

'Memory Usage: 6700K(as per Windows Task Manager)

'Steps to Execute: Double click the vbs file everytime you don't want the autolock to rule over.


Option Explicit

Dim wshShell



'Open shell

Set wshShell= CreateObject("WScript.Shell")

Do While true

wshShell.SendKeys "{SCROLLLOCK}" 'SCROLL LOCK is the least used key...!!

wshShell.SendKeys "{SCROLLLOCK}"


WScript.sleep 30000

Loop

'Quit

msgbox "Done..."

WScript.Quit

Solution for ActiveX error in Automation Object Model code

Many of us experiences the AOM fails to create QTP object to launch and invoke tests and getting ActiveX object error popup.



Active X error will happen due to delay in License Checking. It will resolve, If you Follow below steps.


Navigate to Start>Control Panel>System>Advanced Tab>Environment Variables



1. “LSHOST” variable and click on Edit button.

2. Change variable name from “LSHOST” to “LSFORCEHOST”.

3. In variable value edit box instead of name enter IP address of License server.



Do this for both ‘User variables’ & ‘System variables’.