Take screenshot on command prompt/powershell
I want my script to get a screenshot using command prompt/powershell WITHOUT ANY 3RD PARTY TOOLS how can I do that it should look like this "C:\Windows\System32\screenshot.exe" "C:\Users\%username%\Pictures\screenshot.png"
Solution 1:
Guys I've found a way just replace urusername with your username and run this command
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Width = $Screen.Width
$Height = $Screen.Height
$Left = $Screen.Left
$Top = $Screen.Top
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
$bitmap.Save("C:\Users\urusername\Desktop\MyFancyScreenshot.bmp")
Write-Output "Screenshot saved to:"
Write-Output C:\Users\urusername\Desktop\MyFancyScreenshot.bmp