Last active
December 16, 2019 13:38
-
-
Save eric100lin/434f08c4ebbabba61421c77aa5ef3986 to your computer and use it in GitHub Desktop.
some tip about Windows Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://environmentvariables.org/Main_Page#List_of_Windows_environment_variables | |
*Run command with | |
CMD /C "" #Example: cmd /C "dir" | |
*Run command and do NOT close window | |
CMD /K "" #Exmple: cmd /K "python HelloWorld.py" | |
*Change directory without considering drive letter | |
CD /D "" #Exmple: CD /D "D:\exp" | |
Power shell do NOT need /D | |
*Copy src("hello") folder and rename to dst("world") directory | |
#Exmple: xcopy /Y /E D:\exp\hello D:\exp\world\ | |
It's important to add "\" in destination path | |
*Copy files in src("hello") folder to dst("exp"/"world\OMG\") directory | |
#Exmple: xcopy /Y /E D:\exp\hello\* D:\exp\ | |
#Exmple: xcopy /Y /E D:\exp\hello\* D:\exp\world\OMG\ | |
Will create all folders to the dst path | |
*Windows Startup Scripts | |
*.cmd under C:\Users\<UserName>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup | |
*Windows grep equivalent command in windows | |
java -version 2>&1 | findstr /R "version\ \"1*\.*[89].*\"$" | |
TYPE MY_TEST.txt | findstr "version\ \"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://blog.darkthread.net/blog/powershell-learning-notes/ | |
*Important!! First time to run powershell, you need to Set-ExecutionPolicy if .ps1 is not signed | |
On a 64-bit OS you need to run Set-ExecutionPolicy for 32-bit and 64-bit PowerShell separately | |
Set-ExecutionPolicy RemoteSigned | |
Get-ExecutionPolicy | |
Set-ExecutionPolicy Unrestricted -Scope CurrentUser | |
This will set the execution policy for the current user (stored in HKEY_CURRENT_USER) rather than the local machine (HKEY_LOCAL_MACHINE). | |
This is useful if you don't have administrative control over the computer. | |
*Create full path to ".\dummyfile" and overwrite it if exist | |
New-Item -Path ".\dummyfile" -ItemType File -ErrorAction Ignore -Force | |
*Create full path to ".\dummyfile" without overwrite it | |
New-Item -Path (Split-Path ".\dummyfile") -ItemType Directory -ErrorAction Ignore | |
*Concatenate multiple files into one file | |
Get-Content .\Round?_log.txt | Out-File -Encoding ASCII -Append .\Combined.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
route print | |
route -p add 172.0.0.0 mask 255.0.0.0 10.23.85.254 METRIC 1 IF 17 | |
route -p add 47.0.0.0 mask 255.0.0.0 10.23.85.254 METRIC 1 IF 17 | |
route -p add 10.0.0.0 mask 255.0.0.0 10.23.85.254 METRIC 1 IF 17 | |
route -p add 192.168.0.0 mask 255.255.0.0 10.23.85.254 METRIC 1 IF 17 | |
route -p add 10.23.85.254 mask 255.255.255.255 10.23.85.254 METRIC 1 IF 17 | |
route -p add 192.168.210.0 mask 255.255.255.0 192.168.210.1 METRIC 1 IF 10 | |
route delete 0.0.0.0 | |
route -p add 0.0.0.0 mask 0.0.0.0 192.168.210.1 METRIC 1 IF 1 | |
route -p add 0.0.0.0 mask 0.0.0.0 10.23.85.254 METRIC 2 IF 10 | |
ipconfig /flushdns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://docs.microsoft.com/zh-tw/windows/uwp/launch-resume/launch-settings-app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment