Microsoft Docs Command and Windows Tricks

check the connection to certain pc, and check its ip address:

ping computer fullname -4

to check the computername in command prompt:

set com

or to see the environment variable path:

set

check current user logined information in the OS:

set user

check all port:
netstat -bn
to check who has occupied the port:
netstat -ano| findstr 8080
to show the pid number:
tasklist | findstr 1048
to kill process:
taskkill /pid 1048 /F

to the directory from root drive: cd \foldername

set service start manually:

sc.exe config

sc config serviceName start=demand

start service net connection:

net start servicename

stop service net connection:

net stop servicename

show the share folders for this computer:

net use

delete the existed link: Net Use 命令用法

net use * /delete

map a network shareto a drive letter

eg: net use h: \\<servername>\<sharename>

view network resources:

eg: net view \\<servername>

eg: net view /workgroup:<workgroupname>

use telnet client to a web server on TCP port as follow:

telnet example.com 80

clean the screen:

cls

show planned tasks:

schtasks

checking the current logon user:

query user

check domain user account:

net user XXX /domain

check domain group:

net group XXX /domain

check the ip address of a certain hostname:

nslookup hostname

by a certain DNS server:

nslookup hostname 8.8.8.8

also to check the server name:

eg: nslookup 8.8.8.8

in nslookup dialog, check the ldap server information:

set types=all
_ldap._tcp.domainName

get cpu information from command prompt:

wmic cpu get caption, deviceid, name, numberofcores, maxclockspeed, status

to remote desktop:

mstsc

using batch file to start and stop service automatically, eg:

net start "a service showing name"

net stop"a service showing name"

use ssh to connect to the EC2 instance:

1.ssh -i "XXX.pem" XXX@.domain -L localport:10.19x.xx.xx:serverport

localport can be any port not been used

2.open the mstsc(remote desktop)

computer: localhost:localport

server IP\Administrator

unzip a msi file in command line:

msiexec /a "xxx.msi" targetdir="D:\target_folder" /qn

to recover the installation successfully when using remote desktop:

IBM Spectrum Protect Client のインストールが Windows Server プラットフォーム上でハングする

if you can access a remoted share folder, use \\servername\C$ to access the C drive

register the machine name for a certain ip address:

C:\Windows\System32\drivers\etc\hosts

eg: 127.0.0.1 localhost

check security ID:

wmic useraccount where name='xxx' get sid

How to uninstall .net:

How to uninstall and remove .NET Framework 4.6, 4.7, or 4.8

.NET Framework versions and dependencies

.NET Framework versions and dependencies

safety error about remote desktop:

Windowsで「要求された関数はサポートされていません」でリモートデスクトップ接続出来ない時の暫定対応

how to install Internet Information Services(IIS):

Windows Server 2016 にインターネット インフォメーション サービス (IIS) をインストールする (IIS – Internet Information Service Tips)

Cannot find IIS Service in Windows 7

check hostname:

hostname

start windows task scheduler:windows 10 如何设定计划任务自动执行 python 脚本

Windows+R->taskschd.msc

How To Install OpenSSL on Windows: How To Install OpenSSL on Windows

Keytool for pfx> JKS:

keytool -importkeystore -srckeystore mypfxfile.pfx -srcstoretype pkcs12 -destkeystore clientcert.jks -deststoretype JKS

OpenSSL for CER & PVK file > P12:
openssl pkcs12 -export -name certificationName -in certificationName.cer -inkey certificationName.key -out certificationName.p12

Keytool for p12 > JKS:
C:\tibco\tss\10.3.9\jdk\bin\keytool -importkeystore -destkeystore certificationName.jks -srckeystore certificationName.p12 -srcstoretype pkcs12 -alias certificationName

use remote desktop from server need to set:

How to Disable Internet Explorer Enhanced Security Configuration in Server 2016

get directory information: tree /f > text.txt

open Local Security Policy: secpol.msc

Display the contents of a Kerberos credentials cache or key table: klist

star menu programs shortcut is in: shell:common programs

delete folder within contents: eg: echo y | Rmdir /S "PyCharm Community Edition 2020.2.1"

rd /S “xxx

https://geniushub.io/how-to-delete-files-folders-directories-cmd-windows-command-line-prompt-del-rmdir/

rename file or folder: eg:

rename old.txt new.txt

rename old new

delete file: eg:

del /f file.txt

del *.*

copy file:eg:

copy "xxx.doc" test_folder

copy "xxx.doc" test.doc

move file:eg:

move "xxx.txt" ../

How to create an infinite loop in Windows batch file:

for /l %%x in (1, 0, 10) do (
   echo %%x
)

How to Solve New Simple Volume Greyed out?

如何删除隐藏的Windows10恢复分区

diskpart
list disk
select disk 0
list partition
select partition 2
delete partition override

to install .Appx: PowerShell cmdlets you can use to install an .Appx package, eg:

Add-AppxPackage -Path "C:\Path\to\File.Appx"

How to install .Appx or .AppxBundle on software Windows10

sleep command:

To pause the command processor for ten seconds then make directory:

timeout /t 10 & mkdir xx

To pause the command processor indefinitely until a key is pressed:

timeout /t -1 && rd t

To pause the command processor for 10 seconds and ignore any keystroke:

timeout /t 10 /nobreak

execute only if the first exited successfully:

dir && echo foo

check the malsoftware:mrt.exe

trace the connect: eg: tracert -d yahoo.co.jp

list local NetBIOS names: nbtstat -n

list remote NetBIOS names, referenced by IP address: nbtstat -A 192.168.1.1

list remote NetBIOS names, reference by name: nbtstat -a server1

check the user account in windows:

wmic useraccount list full

disable account:

How to Enable or Disable a User Account in Windows 10

eg: net user HomeGroupUser$ /active:no

create new user($ means hidden):

net user xxx$ pw /add

check the wifi signal: netsh wlan show interface

check the connection of the interface: netsh interface show interface

check the ip address by interface: netsh interface ip show address | findstr "IP Address"

reset the network: netsh winsock reset

get the wifi report: netsh wlan show wlanreport

check current record in resolver cache: ipconfig /displaydns

clear resolver cache: ipconfig /flushdns

check .NET Frame version:

Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version,Release -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select PSChildName, Version, Release

How can I determine my user account’s OU in a Windows domain?

gpresult /r | find "OU"

open firewall by cmd: control firewall.cpl

restart OS immediately by cmd: shutdown -r -t 0

check port is open from outside of server: Test-NetConnection -Port portNumber -ComputerName ipAddress -InformationLevel Detailed

Windows下的chcp命令

eg: chcp 65001 >nul

go to user folder: %USERPROFILE%

release IP: ipconfig /release "WLAN"

renew IP: ipconfig /renew

get dns cache: ipconfig /displaydns | clip

get MAC information: getmac /v

get energy report: powercfg /energy

get energy sleep report: powercfg /sleepstudy /duration 28

get battery report: powercfg /batteryreport

displays file name extension associations: assoc

modifies file name extension associations: assoc .dts=PotPlayerMini64.DTS

Enable/disable firewall: netsh advfirewall set allprofiles state on/off

show the routing table: route print

restart to BIOS immediately: shutdown /r /fw /f -t 0

check certain group belonged context name OU:

dsquery group -samid groupName

check group members by OU context name:

dsget group "CN=aaa,OU=Dept,OU=Auto,OU=Groups,DC=XX,DC=local" -members

check public IP address: curl -L ip.tool.lu

outlook filter: eg:

from:xxx@xxx.com received:4/1/2022..4/30/2022 hasattachments:true

currently used wallpaper: %AppData%\Microsoft\Windows\Themes\CachedFiles

Windows Spotlight Pictures:

%LocalAppData%\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets

How to find your BitLocker recovery key | Microsoft

check the BitLocker state:

manage-bde -status

show the subfolder and included files:

dir "yourPath" /s /b /a-d

Run without Administrator Permission:

Set __COMPAT_LAYER=RunAsInvoker
Start xxx.exe

check the hash value:

CertUtil -hashfile "your File Path" MD5

powershell command to off Windows Defender:

Set-MpPreference -DisableRealtimeMonitoring $true

powershell command to on Windows Defender:

Set-MpPreference -DisableRealtimeMonitoring $false

Altering File Access:

  • Gain Ownership:
    takeown /f xxx.pem
    Grants current user ownership of xxx.pem.
  • Modify Permissions:
    icacls xxx.pem /grant Administrators:F
    Gives Administrators full access to xxx.pem.

Manual Installation of OpenSSH Using PowerShell

  1. Install OpenSSH Server: Open PowerShell as an administrator and run:
    Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
  2. Start SSH Service: Start the service and set it to automatic startup:
    # Get the service named sshd and start it
    Get-Service -Name sshd | Start-Service
    # Get the service named sshd and set its startup type to automatic
    Get-Service -Name sshd | Set-Service -StartupType Automatic

    # Check the status of the service named sshd
    Get-Service -Name sshd
  3. Configure Firewall Rules: Ensure the firewall allows SSH connections:
    New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Disable the startup item:

Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "Wechat"

display hard disk volumes with their sizes in a human-readable format:

Get-Volume | Select-Object FileSystemLabel, DriveType, DriveLetter, @{Name="Size(GB)"; Expression={[math]::Round($_.Size / 1GB, 2)}}, @{Name="FreeSpace(GB)"; Expression={[math]::Round($_.SizeRemaining / 1GB, 2)}}

display memory information in a human-readable format:

Get-ComputerInfo | Select-Object @{Name="TotalPhysicalMemory (GB)"; Expression={[Math]::Round($_.CsTotalPhysicalMemory/1GB, 2)}}, 
                                 @{Name="PhysicallyInstalledMemory (GB)"; Expression={[Math]::Round($_.CsPhyicallyInstalledMemory/1GB, 2)}}, 
                                 @{Name="TotalVisibleMemorySize (GB)"; Expression={[Math]::Round($_.OsTotalVisibleMemorySize/1MB, 2)}}, 
                                 @{Name="FreePhysicalMemory (GB)"; Expression={[Math]::Round($_.OsFreePhysicalMemory/1MB, 2)}}, 
                                 @{Name="TotalVirtualMemorySize (GB)"; Expression={[Math]::Round($_.OsTotalVirtualMemorySize/1MB, 2)}}, 
                                 @{Name="FreeVirtualMemory (GB)"; Expression={[Math]::Round($_.OsFreeVirtualMemory/1MB, 2)}} | Format-Table -AutoSize

display CPU information in a human-readable format:

Get-WmiObject -Class Win32_Processor | Select-Object Name, DeviceID, NumberOfCores, NumberOfLogicalProcessors, AddressWidth, MaxClockSpeed, L2CacheSize, L3CacheSize | Format-Table -AutoSize

show the files in the current directory:

Get-ChildItem | Format-Table Name, @{Name="Size"; Expression={
    if ($_.Length -gt 1GB) {
        "{0:N2} GB" -f ($_.Length / 1GB)
    } elseif ($_.Length -gt 1MB) {
        "{0:N2} MB" -f ($_.Length / 1MB)
    } elseif ($_.Length -gt 1KB) {
        "{0:N2} KB" -f ($_.Length / 1KB)
    } else {
        "$($_.Length) B"
    }
}}, LastWriteTime -AutoSize

delete a file:

Remove-Item -Path '.\yourFileName'

activate windows 10/11:

slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX
slmgr /skms kms8.msguides.com
slmgr /ato

display GPU information in a human-readable format:

Get-WmiObject -Namespace "root\cimv2" -Query "SELECT * FROM Win32_VideoController" | Select-Object Name, @{Name="AdapterRAM(GB)";Expression={[Math]::Round($_.AdapterRAM / 1GB, 2)}}, DriverVersion, VideoProcessor

display GPU detailed information:

Get-WmiObject -Namespace "root\cimv2" -Class Win32_VideoController | Select-Object Name, PNPDeviceID, VideoArchitecture, VideoMemoryType, AdapterCompatibility, AdapterDACType, DeviceID, InstalledDisplayDrivers, Monochrome, Status

activitate windows11:

irm https://massgrave.dev/get | iex

留下评论

通过 WordPress.com 设计一个这样的站点
从这里开始