Outputs Windows Services service name and display name using "sc query", pipes the output to "awk" for processing, then "column" for formatting.
List All Services:
sc query state= all | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
List Started Services:
sc query | awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
List Stopped Services:
sc query state= inactive| awk '/SERVICE_NAME/{printf"%s:",$2;getline;gsub(/DISP.*:\ /,"");printf"%s\n",$0}' | column -ts\:
Show Sample Output
Don't want to log out but you do want to get rid of a stored .zip file password in Windows? This will do that.
Firefox.exe needs to be in the path To enhance: add a sleep... url_list contains urls: D:\>type url_list.txt http://yahoo.com google.com http://fr.news.yahoo.com
In case of mailbox recovery and duplicated task/appointment reminders afterwards.
Like ps on unix, but for windows. Show Sample Output
%t are tens. %d are digits. One may have further outer loops to provide hundreds, thousands, etc. This example applies ping to the numbered machines. The pattern can be used in other ways to apply all combinations of components to a task. Show Sample Output
use the shell default positional parameter syntax ${X:-default} in lieu of testing.
Pass the files path to finfo(), can be unix path, dos path, relative or absolute. The file is converted into an absolute nix path, then checked to see if it is in-fact a regular/existing file. Then converted into an absolute windows path and sent to "wmic". Then magic, you have windows file details right in the terminal. Uses: cygwin, cygpath, sed, and awk. Needs Windows WMI "wmic.exe" to be operational. The output is corrected for easy...
finfo notepad.exe
finfo "C:\windows\system32\notepad.exe"
finfo /cygdrive/c/Windows/System32/notepad.exe
finfo "/cygdrive/c/Program Files/notepad.exe"
finfo ../notepad.exe
Show Sample Output
-secgrp no for distribution -scope u for distribution
Using "wmic get * /value" within any Cygwin shell will return lots of Win/Dos newline junk ie "^M$" at the end of found value line, two lines ("$" Unix newline) above, and three below. This makes storing and or evaluating wmic queries as variables a pain. The method i suggest strips the mentioned junk, only returns the value after "OSArchitecture=", and includes only one Unix style newline. Other methods using sed|awk|cut can only handle the output of wmic cleanly when piped or using multiple sed statements.
wmic OS get OSArchitecture /value | sed 's/\r//g;s/^M$//;/^$/d;s/.*=//'
making
wmic OS get OSArchitecture /value | grep -Eo '[^=]*$'
a much cleaner and slightly less costly alternative.
Show Sample Output
What's wrong with this? Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: