Tuesday, April 21, 2009

nice quote !!

"Time doesn't change things. Doing things changes things. Not doing things leaves things exactly as they were."

Dr. Gregory House

Saturday, April 11, 2009

kill process from vb script (tried on windows xp)

Dim objWMIService, objProcess, colProcess
Dim xComputer, xProcessKill
Dim killed
xComputer = "."
xProcessKill = "'wiamp.exe'"

Killed = 0 'not yet
value = 1

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

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & xProcessKill)
For Each objProcess in colProcess
value = objProcess.Terminate()
If value = 0 Then 'did killed
Killed = 1
End If
Next
' End of WMI Example of a Kill Process

If Killed = 1 Then
MsgBox "I killed it",64,"Yo.."
End If

WScript.Quit

disable/enable network from command line for script

tried on windows xp
get devcon.exe (just search for it) and copy to system32 folder (or in ur path)

get the hardware id for ur network adaptor by using command
devcon findall * > id.txt
open the text file to see the network id
PCI\VEN_8086&DEV_10BD&SUBSYS_82681043&REV_02\3&11583659&0&C8: Intel(R) 82566DM-2 Gigabit Network Connection

copy the line just before &REV...
and run this command
devcon disable "PCI\VEN_8086&DEV_10BD&SUBSYS_82681043"

note the colon
to enable, just replace it with 'enable'
------------

more from internet

I ran the command:

devcon listclass net

which showed all network adapters (real and virtual) on my WinXP
laptop. The first two are the actual hardware adapters, a built in
Ethernet adapter (Intel) and a wireless PCMCIA Ethernet adapter
(Linksys). The results are presented as a "hardware" device ID
followed by a description:

PCI\VEN_8086&DEV_2449&SUBSYS_30138086&REV_03\4&1351887D&0&40F0:
Intel(R) PRO/100 VE Network Connection
PCMCIA\INSTANT_WIRELESS_-_NETWORK_PC_CARD-317F\1 :
Instant Wireless - Network PC CARD

All the remaining "virtual" adapters have id's that begin with
"ROOT...". Therefore I experimented with the command to disable just
the built in Ethernet adapter:

devcon disable =net PCI\VEN*

which illustrates the use of a wildcard character in the "hardware"
ID.

The output from this command was:

PCI\VEN_8086&DEV_2449&SUBSYS_30138086&REV_03\4&1351887D&0&40F0:
Disabled
1 device(s) disabled.

Sure enough, when I went to view the network connections, this adapter
was disabled. I then did the obvious "undo" command:

devcon enable =net PCI\VEN*

which produced the output:

PCI\VEN_8086&DEV_2449&SUBSYS_30138086&REV_03\4&1351887D&0&40F0:
Enabled
1 device(s) enabled.

Even before going back to view the network connections again, I knew
the command had worked because a balloon popped up over the "Local
Area Connection" on my taskbar to inform that "A network cable is
unplugged." (Quite true, since I'm connected by the wireless adapter
to send this message.)
----------------