Windows Scripts


Delete all Windows temp files including user temp directories.

$tempfolders = @(“C:\Windows\Temp\*”, “C:\Windows\Prefetch\*”, “C:\Documents and Settings\*\Local Settings\temp\*”, “C:\Users\*\Appdata\Local\Temp\*”);Remove-Item $tempfolders -force -recurse

Delete files older than ‘x’ days (/D -x):

forfiles /S /P /D -5 "C:\path\to\files" /M "*.*" /C "cmd /C del /Q @path"

Create a PKCS12 (.pfx) cert. You will need the private key and the certificate (not the CSR). The output file can be either .pfx or .p12.

openssl pkcs12 -export -inkey privatekey.key -in certificate.cer -out newcert.pfx

Create a PKCS12 cert and include other certs into chain.

openssl pkcs12 -export -inkey privatekey.key -in certificate.cer -certfile othercert.crt -out newcert.pfx

7zip all files and delete each file once zipped. Requires 7zip CMD line app installed under C:\Program Files\7-Zip.

FOR /F "usebackq tokens=* delims=" %%A IN (`DIR "H:\directory\*.log" /B /S`) DO "C:\Program Files\7-Zip\7za.exe" a "" "%%~fA" & DEL "%%~fA"

Start a VirtualBox guest VM in headless mode

This will allow you to run a VM and log out without losing it. You can also configure this as a Windows scheduled task to have a VM boot automatically when your machine starts. It will start whether or not you login.

VBoxManage startvm "e:\path\to\guestvm.vbox" --type headless

Shutdown or reboot your machine from the command prompt

Reboot immediately. Change ‘0’ to a time in seconds if you would like to delay the reboot.

shutdown -r -t 0

Shutdown immediately. Change ‘0’ to a time in seconds if you would like to delay the reboot.

shutdown -s -t 0

 Force Windows Update to check for updates (Check the ReportingEvents log under C:\Windows\SoftwareDistribution)

wuauclt /detectnow


  • Win+D
    • Instantly transition from Metro to the desktop
    • Show minimized apps after running Win+M
  • Win+M
    • Minimize all open apps to the taskbar (desktop)
  • Win+R
    • Open the RUN command (type one of the below commands and hit enter)
      • cmd
        • Open a command line window
      • msconfig
        • Boot options and other system level options
      • msinfo32
        • System Information
      • devmgmt.msc
        • Device Manager
  • Win+I
    • Settings menu containing Control Panel, Personalization, etc.
  • Win+S
    • Open Search from the desktop. When in Metro, simply start typing to search.