windows 8 - For command not processing lines from a file
2014-04
I dumped all the physical network GUIDs to a file via:
wmic nic where "PhysicalAdapter = 'TRUE'" get GUID > networkAdapterGUIDs.txt
When I try to read the file and echo out its contents nothing happens:
for /F "tokens=*" %%A in (networkAdapterGUIDs.txt) do echo %%A
I have tried %%A
with .bat
files and just %A
when running on the command line.
Here's a screenshot of what I'm seeing:
If I could get a simple echo to work I later planned to do something with the lines that have the GUID on them and omit/skip the first line.
I launched up a fresh Windows 8.1 virtual machine and had the same experience. I am currently running Windows 8.
cmd tools used to have (and obviously still have) problems with Unicode output produced by tools like wmic
. Try to do simple type networkAdapterGUIDs.txt >fixed.txt
and then run your loop over the 'fixed' file
Rob van der Woude's page has also excellent section on those [conversions]
(Feel free to edit the title if you can think of something better)
Is there a command line utility that kills all processes with a specific command line? E.g. kill all processes named "java.exe" with a command line that contains "-jar selenium-server.jar". This is possible through process explorer.
In Windows XP, you can do this easyly uing WMIC, the WMI Console. From a command propt, type the following:
wmic Path win32_process Where "CommandLine Like '%-jar selenium-server.jar%'" Call Terminate
Edit:
I replaced the alias 'process' by it full path ('*path win32_process*') as is Aviator's port. This alias may not be declared on every OS.
If you are using a Windows version which has WMIC command in it. You can try this
wmic path win32_process Where "Caption Like '%java.exe%' AND CommandLine Like '%selenium.jar%'" get ProcessId|more +1
The more +1
removes first line containing the header and prints the PID alone. If there are more than one java process containing selenium.jar then this will return one PID per line.
I believe you could do this with PowerShell using Get-Process and the StartInfo.Arguments on the process you want.
$procs = Get-Process java
foreach($proc in $procs)
{
if($proc.StartInfo.Arguments -contains "-jar selenium-server.jar")
{
kill $proc
}
}
(I haven't tested that completely, but you should be able to tweak it to make it work)
pskill java.exe