Skip to content

Blog

Remove Win10 Icon and Fix Auto Updates

Remove Windows 10 Icon and Fix Auto Updates

  • Run cmd as Administrator
C:\>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\> get-hotfix -id KB3035583, KB2952664, KB2976978, KB3021917, KB3044374, KB2990214

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
MYPCNAME      Update           KB2952664     NT AUTHORITY\SYSTEM  7/15/2015 12:00:00 AM
MYPCNAME      Update           KB2990214     NT AUTHORITY\SYSTEM  4/15/2015 12:00:00 AM
MYPCNAME      Update           KB3021917     NT AUTHORITY\SYSTEM  2/11/2015 12:00:00 AM
MYPCNAME      Update           KB3035583     NT AUTHORITY\SYSTEM  7/17/2015 12:00:00 AM

PS C:\> exit

C:\>wusa /uninstall /kb:2952664

C:\>wusa /uninstall /kb:2990214

C:\>wusa /uninstall /kb:3021917

C:\>wusa /uninstall /kb:3035583

C:\>

C# Log4net Min Usage

Log4Net Minimal Usage

Log4net - minimal info to start.

Step 1


  • Create a project using Visual Studio (the code is in c#).

Step 2


Step 3


  • Create folder lib under the project and place files there.
  • Add reference to lib\log4net.dll

Step 4


  • In the root of the project folder create XML file: log4net.config
  • In Properties for the file set: Copy to Output Directory: Copy if newer
  • Populate file with following
  • log file appender will create a file in logs folder with the file name of output.log;
  • once file size reaches 10MB, new file will be created
  • Maximum of 10 log files will beretained

Sample of log4net.config

<?xml version="1.0" encoding="utf-8" ?>
<log4net xmlns="urn:log4net">
  <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
    <param name="file" value="logs\output.log" />
    <param name="appendToFile" value="true" />
    <param name="rollingStyle" value="size" />
    <param name="maxSizeRollBackups" value="10"/>
    <param name="maximumFileSize" value="10MB" />
    <param name="staticLogFileName" value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="conversionPattern" value="%date [%thread] %-5level %logger - %message%newline" />
    </layout>
  </appender>
  <root>
    <level value="DEBUG"/>
    <appender-ref ref="LogFileAppender"/>
  </root>
</log4net>

Step 5


  • Under the "Properties" of the project in Solution Explorer open up AssemblyInfo.cs
  • Add the following line at the end (ConfigFile points to the configuration file, Watch flag can be set to True to apply updates to the configuration file without restarting the program):
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

Step 6


  • In the file (eq: MyClass) where you want to use log functionality add the following (you can use any string you wish instead of typeof (MyClass). This, however, will indicate which project file was logging):
using log4net;

... class MyClass ...
{
  private readonly ILog Log = LogManager.GetLogger(typeof (MyClass));
  ...
}

Step 7


USAGE:

Log.Debug("This is a debug message");
Log.Info("This is an informational message");
Log.Warn("This is a warning message");
Log.Error("This is an error message");
Log.Fatal("This is a fatal error message");

Additional Comments


  • The log file can be placed anywhere in the filesystem by specifying the path in the log4net.config.
  • Make sure that running user has a CREATE and WRITE permission to logs folder (by default created in the app folder).
  • You can use NUGET to search for log4net. This will take care of steps 2 and 3.

Examples

More Info: http://logging.apache.org/log4net/


Sql Print Sequential Numbers

Print List of Sequential Numbers

-- PRINT OUT LIST OF SEQUENTIAL NUMBERS FROM num_from TO num_to. Max set to up to 9999
DECLARE @num_from int, @num_to int
SELECT @num_from = 1000, @num_to = 1200

SELECT *
FROM (
  SELECT SEQ 
  = 1 * X1.N -- singles
  + 10 * X10.N -- tens
  + 100 * X100.N -- hundreds
  + 1000 * X1000.N -- thousands
  FROM (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X1
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X10
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X100
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X1000
) AS X
WHERE SEQ BETWEEN @num_from AND @num_to
ORDER BY 1

SQL Server - Print All Days of the Year

Print all Days of the Current Year

-- PRINT OUT ALL OF THE DAYS IN THIS YEAR
SELECT DOY 
  = DATEADD(DAY, RC, CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-01-01')
FROM (
  SELECT RC = X1.N + 10 * X10.N + 100 * X100.N
  FROM (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X1
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X10
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X100
) AS X
WHERE YEAR(GETDATE()) = YEAR(
  DATEADD(DAY, RC, CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-01-01')
)
ORDER BY 1

Reset NIC (Network Interface Card) and Firewall Settings

Reset Network Card and Firewall settings

Start from elevated prompt

Reset firewall and NIC configuration states with netsh

Export current active policy of Windows Firewall to a specified file.

```dos netsh advfirewall export %temp%\advfirewall.wfw ````

Restore the Windows Firewall with Advanced Security policy to the default policy. In a Group Policy object, this command returns all settings to not configured and deletes all connection security and firewall rules.

```dos netsh advfirewall reset ````

Resets the BranchCache service. Flushes the local cache. Every configuration parameter of BranchCache will be reset to its default value.

```dos netsh branchcache reset ````

Resets TCP/IP and related components to a clean state.

```dos netsh int ipv4 reset %temp%\ipv4_rst.log ````

Resets IPv6 configuration state.

```dos netsh int ipv6 reset %temp%\ipv6_rst.log ````

Resets Winsock Catalog to a clean state. All Winsock Layered Service Providers which were previously installed must be reinstalled. This command does not affect Winsock Name Space Provider entries.

```dos netsh winsock reset catalog ````

Enable / Disable network card (NIC) using netsh

Show network interfaces (interface name to be used to disable / enable network card).

```dos netsh interface show interface ````

Disable network interface by name

```dos netsh interface set interface name="Local Area Connection" admin=disabled ````

Enable network interface by name

```dos netsh interface set interface name="Local Area Connection" admin=enabled ````

Enable / Disable network card interface using WMIC

Get NIC list and index number:

```dos wmic nic get name, index ````

Enable NIC with index number: (eg: 7)

```dos wmic path win32_networkadapter where index=7 call enable ````

Disable NIC with index number: (eg: 7)

```dos wmic path win32_networkadapter where index=7 call disable ````

Enable by name

```dos wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call disable ````

Disable by name

```dos wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call enable ````