Knowledge
  • Read Me
  • Programming
    • ASP.NET
      • .NET Libraries
      • ASP.NET Core
        • Helper
          • Encryption
          • CSV Helper
          • String Helper
        • Logging
          • Simple Serilog
        • Middlewares
          • IP Restrictions
          • Request Throttling
          • Request Logging
        • Console
          • Command Line with arguments
        • JSON
      • ASP.NET Framework
      • Testing
        • Resources
        • xUnit.net
      • Naming Conventions
      • REST API Guidelines
    • Database
      • SQL Style Guide
      • MSSQL
        • Installation
          • Install MSSQL on MacOS M1 (ARM64)
        • Looping
        • Table Valued Functions
        • Session State
        • SQL Cheat Sheet
        • Export Pipe Delimited CSV With cmdshell
      • Redis
        • Redis Installation on Mac OS
        • Redis Installation on Docker
    • Java
      • AWS SDK - SSM
      • mTLS HTTP Connection
      • Read Resource Files
    • Javascript
      • Javascript Libraries
    • Python
    • OpenSSL
      • One Way SSL & Two Way SSL
      • Common OpenSSL Commands
      • Create Self-Signed Certificate
    • Misc
      • Git Commands
      • Windows Commands
      • PowerShell Commands
      • Vulnerabilities Dependency Check
      • Replace Filename Command
      • JSON Web Token (JWT)
      • Rabbit MQ Message-Broker
      • Pandoc Convert Document
  • DevOps
    • What is DevOps
    • CI & CD
    • Azure DevOps
  • Tools
    • Development Tools
Powered by GitBook
On this page
  • Useful Commands
  • List filenames in directory
  • List directory tree
  • Command History
  • IP Configuration
  • IP Configuration utility to remove the DNS cache
  • NETSTAT: Network Statistics
  • PING: Send Test Packets
  • TRACERT: Trace Route
  • TELNET
  • NSLOOKUP
  • SYSTEMINFO: System Information
  • EXECUTE COMMAND WITH INPUT
  • Reference

Was this helpful?

  1. Programming
  2. Misc

Windows Commands

Useful Commands

List filenames in directory

dir /b /a-d

List directory tree

# To display the names of all the subdirectories on the disk in your current drive, type:
tree \

# To display, one screen at a time, the files in all the directories on drive C, type:
tree c:\ /f | more

# To print a list of all the directories on drive C, type:
tree c:\ /f  prn

Command History

doskey /history

IP Configuration

ipconfig 

IP Configuration utility to remove the DNS cache

ipconfig /flushdns

NETSTAT: Network Statistics

netstat

PING: Send Test Packets

ping google.com

TRACERT: Trace Route

tracert google.com

TELNET

telnet [domain name or ip] [port]

#example: telnet 192.168.0.10 25

NSLOOKUP

nslookup [domain name or ip]

#example: nslookup google.com

SYSTEMINFO: System Information

systeminfo

EXECUTE COMMAND WITH INPUT

Sometimes we need to request new AWS session token with MFA enabled in order to update the session token credentials when it is expired.

For example: aws sts get-session-token --serial-number arn:aws:iam::123456789012:mfa/yourawsuser --token-code %otp% --profile yourprofile

If you do this manually and very frequent, you may consider to create a simple Batch Script file to prompt you to enter the MFA OTP.

@ECHO off
cls

GOTO start

REM <The BEGIN Label>
:start
ECHO.
ECHO --------------------------------------------------------
ECHO *** Request AWS Session Token ***
ECHO --------------------------------------------------------

REM - prompt input for one time passcode
SET /p otp="Enter OTP: "

ECHO OTP is %otp%

REM - prepare command
SET command="aws sts get-session-token --serial-number arn:aws:iam::{REPLACE_YOUR_AWS_ID_HERE}:mfa/{YOUR_AWS_USER} --token-code %otp% --profile {YOUR_PROFILE}"

REM - execute the command in a seperate shell console
start cmd /k %command%

REM - prompt do you wish to request a new one or exit.
GOTO retry_or_exit
REM </The BEGIN Label>

REM <RETRY or EXIT Label>
:retry_or_exit
@ECHO off
cls
ECHO.
ECHO --------------------------------------------------------
ECHO  Y - Retry
ECHO  n - Exit
ECHO --------------------------------------------------------

REM - prompt input for choice
SET /p choice="Do you want to retry or exit? [Y/n]"

REM - handle choice
IF '%choice%'=='Y' GOTO start
IF '%choice%'=='y' GOTO start
IF '%choice%'=='N' GOTO end
IF '%choice%'=='n' GOTO end

REM - prompt for input again if invalid choice is provided   
ECHO "%choice%" is not valid, try again
GOTO retry_or_exit

PAUSE
REM </RETRY or EXIT Label>

REM <THE END Label>
:end 
REM </THE END Label>

Reference

PreviousGit CommandsNextPowerShell Commands

Last updated 2 years ago

Was this helpful?

Windows commands