Commands tagged windows (84)

  • Functionally the same as the Microsoft Robocopy (https://en.wikipedia.org/wiki/Robocopy) command below but with the benefits of compression and optionally specifying a user. robocopy /e [//host]/source/path [//host]/destination/path Options: -a: archive mode - rescursive, copy symlinks as symlinks, preserve permissions, preserve modification times, preserve group, preserve owner, preserve device files and special files -hh: Numbers in human-readable K=1024 format. Single "h" will produce human-readable K=1000 format -m: don't copy empty directories -z: use compression (if both source and destination are local it's faster to omit this) --progress: Shows progress during the transfer and implies --verbose (verbose output) --stats: Summary after the transfer stops Show Sample Output


    0
    rsync -ahhmz --progress --stats [[user@]host:]/source/path/ [[user@]host:]/destination/path/
    juangmorales · 2014-11-13 18:52:45 20
  • Also resolves hostname


    0
    nslookup . ifcfg.me
    Eun · 2014-11-17 09:35:28 7

  • 0
    netstat -anop tcp | find ":8010"
    ferantivero · 2014-12-23 13:04:54 8
  • IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type powershell Create a log file of your Motorola Surfboard SB6141 downstream signal strengths. Uses the built-in curl to request signal strength data from your SB6141 cable modem. HTML page 192.168.100.1/cmSignalData.htm has the signal strength numbers for the 8 downstreams. Some HTML/DOM processing parses out the 8 values from the above page. The eight extracted signal strengths are then logged to a file. A small while-loop watches the clock & repeats the process every 10 seconds. Show Sample Output


    0
    while(1){while((date -f ss)%10-gt0){sleep -m 300} echo "$(date -u %s) $((curl 192.168.100.1/cmSignalData.htm).parsedhtml.body.childnodes.item(1).firstchild.firstchild.childnodes.item(5).outertext|%{$_ -replace '\D+\n',''})">>modemlog.txt;sleep 1;echo .}
    omap7777 · 2015-12-24 02:12:10 11
  • IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type powershell Uses sajb to start a PowerShell background job that pings an IP host every 10 seconds. Any changes in the host's Up/Down state is time-stamped and logged to a file. Date/time stamps are logged in two formats: Unix and human-readable. A while(1) loop repeats the test every 10 seconds by using the sleep command. See the Sample Output for more detail. I use this command to log Up/Down events of my Motorola SB6141 cable modem (192.168.100.1). To end the logging, close the PowerShell window or use the "exit" command. Show Sample Output


    0
    sajb {$ip="192.168.100.1";$old=0;while(1){$up=test-connection -quiet -count 1 $ip;if($up-ne$old){$s=(date -u %s).split('.')[0]+' '+(date -f s).replace('T',' ')+' '+$ip+' '+$(if($up){'Up'}else{'Down'});echo $s|out-file -a $home\ping.txt;$old=$up}sleep 10}}
    omap7777 · 2015-12-28 20:33:08 15
  • List local accounts and their SIDs (*-500 is the original local Administrator, *-501 is the original local Guest, more below). This is helpful in identifying local accounts that are not disabled, don't have an expiring password, etc. Well-Known SIDs https://support.microsoft.com/en-us/kb/243330 Show Sample Output


    0
    wmic useraccount WHERE "LocalAccount=1" GET Name,Disabled,Lockout,PasswordChangeable,PasswordExpires,PasswordRequired,SID
    Xeleema · 2015-12-29 18:01:42 10
  • Unblock multiple windows files using Powershell. -Recurse is optional to apply to all directories recursively.


    0
    dir c:\mydir -Recurse | Unblock-File
    Denhams · 2016-02-12 17:02:14 22
  • Commandline for windows + cygwin with specific interface and resolved ip.


    0
    ssh root@server.com "tcpdump -i INTERFACE_NAME -U -nnn -s0 -w - 'port 80'" | /cygdrive/c/Program\ Files/Wireshark/Wireshark.exe -N mnNtCd -k -i -
    artembeloglazov · 2016-03-02 13:42:29 12
  • The Windows Subsystem for Linux (WSL) is a compatibility layer for running binary Linux executables natively in Windows. A folder such as "C:\Program Files (x86)\Common Files" is represented as "/mnt/c/Program Files (x86)/Common Files". This function allows you to change the current directory to a Windows folder. Show Sample Output


    0
    function _cd() { local dir; dir="$(sed -e 's~\([a-z]\):~/mnt/\L\1~gi' <<< "${*//'\'/"/"}" )"; if [ -d "$dir" ]; then cd "$dir" || exit; fi; }
    mikhail · 2019-06-06 17:53:28 40
  • Lower PowerShell priority, so that to launch processes in the background and work normally with other applications Show Sample Output


    0
    PS> Get-WmiObject Win32_process -filter 'name = "powershell.exe"' | Foreach-Object { $_.SetPriority(16384) }
    pascalvaucheret · 2022-06-16 14:53:28 370
  • Bulk downloads the comic strip JPG files for the adult cartoon Savitabhabhi, storing each set in it's own folder. Requires manual removal of "non-image" files that maybe created because each series may differ in length. The command can be easily adapted for UNIX flavours. You need to have cURL in your path.


    -1
    for /L %%x in (1,1,16) do mkdir %%x & curl -R -e http://www.kirtu.com -o %%x/#1.jpg http://www.kirtu.com/toon/content/sb%x/english/sb%x_en_[001-070].jpg
    MyTechieself · 2009-12-08 15:01:16 7
  • Usually the MS-DOS cmd.exe processes in the whole FOR loop as one command and expands each var like %varname% in before (except the loop var of course). This command enables expansion of other vars than only the loop var during the FOR loop. The syntax of the var to expand is then !varname! inside the FOR loop. Use command endlocal to end the setlocal command. E.g. (only works from batch files, not from commandline directly): @echo off setlocal enabledelayedexpansion FOR %%A IN (*) DO ( set file=%%A echo !file! ) endlocal


    -1
    setlocal enabledelayedexpansion
    Marco · 2010-08-10 12:26:43 6
  • The command line can be accessed by using the cmd command which will open a command window with a DOS interface. The command line is a throw back to the early days of computing before there was a Windows interface. Show Sample Output


    -1
    echo %logonserver%
    0disse0 · 2011-06-13 09:52:51 6

  • -1
    sed 's/.$//' Win-file.txt
    totti · 2011-09-15 19:07:51 4
  • This command should be copy-pasted in Windows, but very similar one will work on Linux. It uses wget and sed.


    -1
    wget --no-check-certificate https://code.google.com/p/msysgit/downloads/list -O - 2>nul | sed -n "0,/.*\(\/\/msysgit.googlecode.com\/files\/Git-.*\.exe\).*/s//http:\1/p" | wget -i - -O Git-Latest.exe
    michfield · 2012-11-14 08:17:50 8

  • -1
    cls && ipconfig | findstr -R "[ IPv4 | adapter ]"
    sameer666 · 2013-12-03 13:29:30 5
  • also shows the ethernet adapter Show Sample Output


    -1
    cls && ipconfig | findstr -R "[ IPv4 | adapter ]"
    sameer666 · 2013-12-03 13:31:00 6

  • -1
    net user USERNAME /domain
    shawn_abdushakur · 2014-01-02 20:22:46 7

  • -1
    %0 | %0
    imjoseangel · 2017-05-17 14:17:01 22
  • Loops over array of a system var, splits its values and puts the values into %A, %B, %C, %D, and so on. Create array before, like set ARRAY[0]=test1,100 and set ARRAY[1]=test2,200 Be sure to replace %A, %B, etc. with %%A, %%B, etc. when using this from inside of batch files. Show Sample Output


    -2
    FOR /F "tokens=3* delims=[]=," %A IN ('SET ARRAY[') DO ( echo %A -- %B )
    Marco · 2010-08-10 12:12:27 5
  • How to add an "alternate access mapping" from the command line and avoid passing on Friday evening following the interpretation of the all-too-terse "log" of SharePoint?


    -2
    stsadm -o addalternatedomain -url http://paperino.paperopoli.com -urlzone Internet -incomingurl http://quiquoqua.paperopoli.com
    0disse0 · 2011-07-09 11:32:45 3
  • Interacting with Active Directory to add users from one group to another group. This prevents from having to deal with long DNs and copying, pasting problems. It executes once per returned object.


    -3
    for /F "DELIMS=""" %i in ('dsquery group -name SourceGroupName ^| dsget group -members') do dsquery group -name TargetGroupName | dsmod group -addmbr %i
    miketheman · 2009-09-25 16:32:33 10
  • This command defragment the SQLite databases found in the home folder of the current Windows user. This is usefull to speed up Firefox startup. The executable sqlite3.exe must be located in PATH or in the current folder. In a script use: for /f "delims==" %%a in (' dir "%USERPROFILE%\*.sqlite" /s/b ') do echo vacuum;|"sqlite3.exe" "%%a" Show Sample Output


    -3
    for /f "delims==" %a in (' dir "%USERPROFILE%\*.sqlite" /s/b ') do echo vacuum;|"sqlite3.exe" "%a"
    vutcovici · 2010-01-18 20:56:00 6
  • This command loops over all indexes of the system variable array ARRAY[] and puts its content into %A. Create this array before, e.g. by set ARRAY[0]=test1 and set ARRAY[1]=test2 For using inside of a batch file, write %%A instead of %A. Show Sample Output


    -3
    FOR /F "tokens=3* delims=[]=" %A IN ('SET ARRAY[') DO ( echo %A )
    Marco · 2010-08-10 12:08:26 4
  • wmi

    Get windows version with servicepack and hostname Show Sample Output


    -3
    wmic -U DOMAIN/user --password='password' //IP_HOST "select Caption,CSDVersion,CSName from Win32_OperatingSystem" | grep Windows
    dr_gogeta86 · 2010-09-20 14:23:37 129
  •  < 1 2 3 4 > 

What's this?

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.

Share Your Commands


Check These Out

Remount root in read-write mode.
Saved my day, when my harddrive got stuck in read-only mode.

most used unix commands

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

how to export a table in .csv file
Exports the result of query in a csv file

List Threads by Pid along with Thread Start Time
This command will list all threads started by a particular pid along with the start time of each thread. This is very valuable when diagnosing thread leaks.

Create a tar archive using xz compression
Compress files or a directory to xz format. XZ has superior and faster compression than bzip2 in most cases. XZ is superior to 7zip format because it can save file permissions and other metadata data.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Create a QR code image in MECARD format
Add the QR code image on your webpage, business card ., etc, so people can scan it and quick add to their Contact Address Book. Tested on iPhone with QRreader.


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: