Useful Windows Commands

Here's a quick post about some useful Windows commands, these can get you out of trouble if you don't have admin rights on a user account and other tricky situations...:

  • Runas elevated command prompt:

    • General Usage:

      Runas /user:%domain%\%username% %command%
      
    • Example:
      Runas /user:mydomain\myaccount cmd

  • Uninstall an application:
    • appwiz.cpl (This opens add/remove programs)
  • Manage local users and groups on a remote machine:

    • General Usage:

      Lusrmgr.msc -a /computer=%computername%
      
    • Example:

      Lusrmgr.msc -a /computer=deepthought
      
    • Full Descriptions: Your domain account does not have admin rights on the remote machine? Synchronize your local admin password with the local admin password on the remote machine. Then open a runas window on your system as the local admin and run the local users and groups console (lusrmgr.msc) targeted to the remote machine and give your domain account access.

  • Activate Hidden Administrator Account:

    • Enable:

      net user administrator /active:yes
      
    • Disable:

      net user administrator /active:no
      
  • Dism Commands in Windows 8:

    • In Windows 8 Imagex has been depracated and the command to use nowadays is DISM. Dism can do all of the same things that imagex could do such as append images to one another expanding the index size for 1 to many. Also, It can apply images and add drivers to and freshly installed Windows Installation.
    • This command goes through a folder adding all .inf files that apply:

      dism.exe /image:C:\ /Add-Driver /Driver:C:\drive_location /Recurse /ForceUnsigned
      
    • Apply an image:

      dism.exe /apply-image /imagefile:D:\monkey.wim /index:1 /ApplyDir:C:\
      
    • Capture an image:

      Dism /Capture-Image /Compress:maximum /ImageFile:{PATH TO WIM} /CaptureDir:{DRIVE TO CAPTURE} /Name:"My Windows partition"
      
  • Native booting VHDS

    • Create VHD with Diskpart For production environments the Microsoft recommends using fixed VHD type:

      create vdisk file=C:\VHDs\{name}.vhd maximum={MAXMB} type=expandable    
      select vdisk file=C:\VHDs\{name}.vhd
      attach vdisk
      create partition primary
      format fs=ntfs quick
      assign letter={VHDLetter}
      
    • Setting VHD as a Native Boot option (Source: VHD)

      cd {VHDLetter}:\windows\system32
      bcdboot {VHDLetter}:\windows