Posts

Showing posts from 2017

How to Clean up the WinSxS Directory and Free Up Disk Space on Windows Server 2008 R2 with New Update

Get KB2852386 for Windows 2008R2 and Windows 7 from below locations: http://www.catalog.update.microsoft.com/Search.aspx?q=2852386 https://www.microsoft.com/en-us/download/details.aspx?id=42739 Server needs to be rebooted after this update installed. Install Desktop Experience feature. When installing Desktop Experience, it does require additional features. Select the button to Add Required Features and click Next and then Install. A reboot is required to finalize the install. Run cleanmgr.exe. Several options are provided for cleanup, including a new option for Windows Update Cleanup. Just like the Windows 7 cleanup, mileage will vary. Also like Windows 7, the actual cleanup occurs during the next reboot. After the reboot, taking a look at the WinSxS directory, it has shrunk. Other options: If you have applied SP1 and have not cleaned up afterwards, I’d highly recommend doing so by running the following command from an administrative command prompt: dism /online /cleanup-i

[Batch file] - Output of a command to variable

If you want to set the output of a command to a value you have to capture it in a  for  statement like this: for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "OS Name"') do set OS_Name=%%a Then remove the leading spaces like this: (there is probably a better way to do this) for /f "tokens=* delims= " %%a in ("%OS_Name%") do set OS_Name=%%a A few things to note here: 1.)  "tokens=2 delims=:"  is setting the delimiter to  :  and it is selecting the second section only, which will pull only the part you want.  2.) the  |  is escaped with a  ^ , this needs to be done in  for  loops or anything after that will attempt to execute as seperate commands.  3.)  "tokens=* delims= "  The token here is * which is all tokens. ======================= Examples of WMIC output to variables: echo WMIC output to variables for /f "usebackq tokens=1,2 delims==|" %%I in (`wmic os get name^,version /format:l

Batch Script to find the version of .Net framework installed on the PC

Method1: @echo off   setlocal   set alias=Reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP"   FOR /F "TOKENS=6 DELIMS=\." %%A IN ('%alias%') DO set .NetVer=%%A   ECHO The most current version of Net in use is %.NetVer% Method2: dir %windir%\Microsoft.Net\framework\v* Output: C:\>dir %windir%\Microsoft.Net\framework\v*  Volume in drive C has no label.  Volume Serial Number is 60F4-4F6D  Directory of C:\Windows\Microsoft.Net\framework 02/25/2016  04:56 AM              v1.0.3705 07/14/2009  10:37 AM              v1.1.4322 02/14/2017  09:27 AM              v2.0.50727 11/21/2010  08:26 AM              v3.0 10/14/2013  09:28 PM              v3.5 03/16/2017  09:37 AM              v4.0.30319 04/05/2016  02:03 PM              VJSharp                0 File(s)              0 bytes                7 Dir(s)  31,032,090,624 bytes free C:\>

Getting values using wmic

wmic computersystem get /value Displays all computer system values as list ================================= The below wmi command gives the OS and the service pack version. wmic os get Caption,CSDVersion /value Output: Caption=Microsoft Windows 7 Enterprise CSDVersion=Service Pack 1 ========================== Filtering with "where": wmic logicaldisk where drivetype=3 get description,name Ref: http://www.cryer.co.uk/brian/windows/batch_files/how_to_list_drive_letters.htm https://ss64.com/nt/wmic.html In a batch file: @echo off for /f "tokens=2 delims==" %%d in ('wmic logicaldisk where "drivetype=3" get name /format:value') do echo %%d

[Windows driver store] Add/remove driver package to the driver store using PnPUtil

PnPUtil (PnPUtil.exe) is a command line tool that lets an administrator perform the following actions on  driver packages : Adds a driver package to the  driver store . Deletes a driver package from the driver store. Enumerates the driver packages that are currently in the driver store. Only driver packages that are not in-box packages are listed. An  in-box  driver package is one which is included in the default installation of Windows or its service packs. Usage: ------ pnputil.exe [-f | -i] [ -? | -a | -d | -e ] Examples: pnputil.exe -a a:\usbcam\USBCAM.INF      -  Add package specified by USBCAM.INF pnputil.exe -a c:\drivers\*.inf                       - Add all packages in c:\drivers\ pnputil.exe -i -a a:\usbcam\USBCAM.INF   -  Add and install driver package pnputil.exe -e                                              - Enumerate all 3rd party packages pnputil.exe -d oem0.inf                               - Delete package oem0.inf pnputil.exe

Adding IPv6 route using Nesh

netsh interface ipv6 add route "Route" "InterfaceName" "InterfaceGW" store=persistent Sample Route: 2a00:da9:ff02:622::/64 InterfaceName:nic2-admin InterfaceGW : 2a00:da9:1:2014:ff2e::1