dos commands and windows commands

I am in the process of putting my notes into web pages, please keep checking in later for more contents
get process  du:folder size  df:disk space  find filename  email_powwershell  last_boot_time  users_and_groups  rdp:remote_desktop  7za  outlook  loop_and_sleep 

Shortcut Key Combination

Press WindowKey, in search box type cmd, and then press CTRL+SHIFT+ENTER: open command prompt in administrator mode
shift + right mouse click --> open command prompt here, Open command promot in current folder
Windows Key: bring up Start Menu 
ctrl+shift+esc --> open task manager
Windows Logo+Break: System Properties dialog box
Windows Logo+C: Opens Control Panel

Windows Logo+D: Minimizes all open windows and displays the desktop
Windows Logo+M: Minimize all
SHIFT+Windows Logo+M: Undo minimize all

Windows Logo+L: Lock the computer (without using CTRL+ALT+DELETE)

Windows Logo+R: Run dialog box

ESC: Equivalent to clicking the Cancel button, Especially useful in Excel

CTRL+ESC: Open Start menu
ALT+TAB: Switch between open programs
ALT+F4: Quit program
SHIFT+DELETE: Delete item permanently

CTRL+Z: Undo
CTRL+B: Bold
CTRL+U: Underline
CTRL+I: Italic

dos programming

The caret (^) symbol is the cmd.exe line-continuation character 
that allows you to continue a command on multiple lines

echo This is a line ^
    and this is more ^
    and this is still more stuff to echo.


7za -?
7za a -tzip -v1g myfile.dmp -mx0 -pmypassword
7za a -tzip -v1g myfile.dmp -mx4 -pmypassword

# in unix or lunix
ls *.DMP|awk '{print "7za a -tzip " $1".zip " $1 " -mx0 -pmypassword"}'
ls *.DMP|awk '{print "7za a -tzip " $1".zip " $1 " -mx4 -pmypassword"}'

a: add files
d: Delete Files from archive
e: Extract file from archive
x: eXtract files with full paths
l: List contents of archive

-tzip: type is zip, -t7z, -tiso or -tudf 
-v1g: split file for 1GB, -v1024m
-mx0: level 0, no compression
-r: Recursive to subdirectories
-ssc: case-insensitive matching for wildcard search


7z x -oC:\Doc
-oC:\Doc:    extract all files to the Doc folder on the C: drive



ipconfig /registerdns

net use

rem remote desktop
mstsc /v:myservername
mstsc /admin /v:myservername

rem services: services.msc

rem task scheduler: taskschd.msc
%windir%\system32\taskschd.msc /s

rem Disk Management
diskmgmt.msc -- disk management, change drive letter for VM(Virtual Machine)
compmgmt.msc -- Computer Management

local security policy

eventvwr -- Event Viewer

WIndows Firewall: firewall.cpl
Windows Firewall with Advanced Security: wf.msc wf.msc and neighbor content

netsh advfirewall show currentprofile netsh 




Find Files: Powershell

find drive script:
Get-ChildItem -Path . -Filter drive*.sql -Recurse

powershell -Command "dir p:/2014*/*/*/*%1*"

Get Processes

get-process|gm -View Extended
Get-Process | Where-Object {$ -eq 'conHost'}
Get-Process | Where-Object {$ -eq 'conHost'}|Format-Table -Property handles,name,Path


Get current folder size: Powershell

Get-ChildItem . -recurse| Measure-Object -property length -sum 
Get-ChildItem . -recurse| Measure-Object -property length -sum| Select-Object sum|format-list
Get-ChildItem . -recurse| Measure-Object -property length -sum| Select-Object sum|format-wide

Get-ChildItem . -recurse| Measure-Object -property length -sum|select @{LABEL='sum(mb)';EXPRESSION={"{0:N2}" -f ($_.sum/1MB)}}|format-list

# -- -----------------------------------------------------------------------

# sub folders size
$mySubDir = (Get-ChildItem | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)
foreach ($i in $mySubDir)
$v = (Get-ChildItem $i -recurse| Measure-Object -property length -sum)
$i.FullName + "     " + "{0:N2}" -f ($v.sum / 1MB) + " MB"


disk space: Powershell

# current disk drive space info
gwmi win32_volume|`
select driveletter, label,`
@{LABEL='GBTotalSpace';EXPRESSION={"{0:N2}" -f ($_.Capacity/1GB)}},`
@{LABEL='GBfreeSpace';EXPRESSION={"{0:N2}" -f ($_.freespace/1GB)}}|`
sort-object -property driveletter

# current disk drive space info
gwmi win32_volume | select driveletter, label, @{LABEL='GBfreespace';EXPRESSION={"{0:N2}" -f ($_.freespace/1GB)}}|sort-object -property driveletter

gwmi win32_volume -Filter 'drivetype = 3' | select driveletter, label, @{LABEL='GBfreespace';EXPRESSION={"{0:N2}" -f ($_.freespace/1GB)} }|sort-object -property driveletter

$dA=Get-WmiObject -Class Win32_LogicalDisk -ComputerName MYSERVERNAME

foreach ($d in $dA ) {
if ( $d.Size) {
"$($d.deviceid) $([math]::Round($($($d.FreeSpace)/(1024*1024*1024)),2)) $([math]::Round($($($d.Size)/(1024*1024*1024)))) $($d.volumeName) "

find filename in sub directory

search sub directory:
dir /s *myfilename_substring*
output: X:\...\mydirectory_name\
output: myfilename_fullname

Test Email: Powershell

send-mailmessage -to "" -from "oracle user <>" -subject "Test mail"  -smtpServer ''

Last Boot Time: Powershell

# powershell
Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime

rem dos and windows
wmic OS GET LastBootUpTime

rem take long time to get
systeminfo | find /i "Boot Time"

net stats srv

net statistics workstation
net statistics workstation | findstr /i since
net statistics workstation | find "Statistics since"

Remote Desktop

shortcut key  2 
CTRL+ALT+BREAK   full-screen or window mode
ALT+INSERT       similar to ALT+TAB
Windows Temp Files:
C:\Documents and Settings\username\Local Settings\Temp

dos loop and sleep

-- sleep command in dos is timeout: eg: timeout 10
rem monitor_01_loop.bat

call monitor_01.bat
timeout 3
goto :BEGIN

Users And Groups

dsa.msc "Active Directory Users and Computers"

Installing RSAT ( Remote Server Administration Tools ) 
dos command list 

Identify members of a local group 

Managing local groups from the command line 

set MYUSERNAME=myusername
net user %MYUSERNAME% /domain
rem not working: dsquery user -name  *%MYUSERNAME%*

net user myusername /domain
dsquery user -name  *myusername*

# list member of localgroup
net localgroup administrators
# net localgroup administrators mydomainname\myusername /add

# sometimes worked
net localgroup mydomaingroupname /domain

# list domain group member in current domain
net group mydomaingroupname /domain
net group "my domain group name" /domain
net group "my domain group name" /domain|find /I /C "%USERNAME%"

# dsget group "CN=GroupName,DC=domain,DC=name,DC=com" -members

dsget group "CN=mydomaingroupname,DC=subdomain,DC=microsoft,DC=com" -members
dsget group "CN=mydomaingroupname,DC=subdomain,DC=microsoft,DC=com" -members -expand

dsquery group -name  mydomaingroupname
dsquery group -samid  mydomaingroupname
dsquery group -name  *mydomaingroupname*
dsget group "CN=mydomaingroupname,OU=Groups,DC=subdomain,DC=microsoft,DC=com" -members
dsget group "CN=mydomaingroupname,OU=Groups,DC=subdomain,DC=microsoft,DC=com" -members -expand

dsquery group -samid "Group_SAM_Account_Name" | dsget group -members -expand
dsquery group -name "Group Account Name" | dsget group -members -expand
dsquery group -name mydomaingroupname | dsget group -members | dsget user -display

# Powershell
# Import-Module ActiveDirectory
Get-ADGroupMember "mydomaingroupname" -recursive
Get-ADGroupMember "mydomaingroupname" -recursive | Select-Object name
Get-ADGroupMember "mydomaingroupname" -recursive | Select-Object name,SamAccountName

Find A user's Windows Groups

rem Find A user's Windows Groups
rem In DOS
net user myusername /domain
net user myusername /domain|findstr /i password|findstr /i expires

dsquery user -name  *myusername*

# In Powershell
Get-ADUser myusername -Properties MemberOf | Select -ExpandProperty memberof|sort
Get-ADPrincipalGroupMembership myusername | select name
Get-ADPrincipalGroupMembership myusername | select name | sort name

List All Of the Users In A Windows Group

rem List All Of the Users In A Windows Group
rem In DOS
net user localgroup Administrators

# powershell

Get-ADGroupMember -Identity $GroupName -Recursive | `
Where {$_.ObjectClass -eq 'user'} | `
Get-ADUser -Properties Title,Department | `
Select SamAccountName,Name,Title,Department 
top top


To recall or replace a message, follow these steps:
1):Locate the Sent Items folder. 
2):Open the message that you want to recall or replace. 
3):Click Actions on the ribbon or menu, and then click Recall This Message. 
4):Enable the Delete unread copies of this message option to recall the message. 
Or, enable the Delete unread copies and replace with a new message to replace the message with a new one.
5):To receive a notification about the success of the recall or replacement, 
enable the Tell me if recall succeeds or fails for each recipient option.
6):Click OK. If you chose the replace option, type your new message and send it.
outlook: ctrl-a ctrl-q: market all email as read
outlook: View HTML content in Web Browser
         Action Panel -- View In Browser
excel: data--> Refresh All