Saturday, April 9, 2016

Encryption and Decryption of Connection Strings in Web.config File via command line

Encryption and Decryption of Connection Strings in Web.config File

You can encrypt and decrypt the tags in web.config file using command line.

Go to command prompt:
Then go to the respective framework.

For encryption and decryption of "connectionStrings" tag

Encrypt:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pe "connectionStrings" -app "/appname"

Decrypt:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pd "connectionStrings" -app "/appname"

For encryption and decryption of "appSettings" tag

Encrypt:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pe "appSettings" -app "/appname"

Decrypt:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pd "appSettings" -app "/appname"


Sunday, December 8, 2013

To get the complete version of SQL Server

To get the complete version of SQL Server

You can use the command below in a new query window of SQL Server.

select @@VERSION

Alternate commands:
SELECT
SERVERPROPERTY('Edition') AS Edition,
SERVERPROPERTY('ProductVersion') AS ProductVersion,
SERVERPROPERTY('ProductLevel') AS ProductLevel


To get the dll from the GAC(Global Assembly Cache)

To get the dll from the GAC(Global Assembly Cache)

For Pre-defined assemblies, type the below command in Run prompt

%windir%\assembly\gac

For the custom(user) dll

%windir%\assembly\GAC_MSIL

Wednesday, October 2, 2013

Rename multiple files in a folder incrementally using this batch file

Rename multiple files in a folder incrementally using this batch file


::Setup the stage...
SETLOCAL ENABLEDELAYEDEXPANSION
SET folder=D:\ABC
SET count=1
::Action
CD "%folder%"
FOR %%F IN ("*.jpg") DO (
 MOVE "%%F" "!count!.jpg"
 SET /a count=!count!+1
)
ENDLOCAL

Note: Put this batch file in that folder where other files that needs to be renamed are available and then run the same. 

Saturday, April 27, 2013

Email not sent until application closes in C#

Email not sent until application closes in C#

It may happen that your email via SMTP will not get sent until the application closes in C#.net

To send the email immediately and at the same time the application is working, you can include the below mentioned line of code:

System.Net.ServicePointManager.MaxServicePointIdleTime = 1

Saturday, April 13, 2013

Creating batch file for Scheduled Task Count


Creating batch file for Scheduled Task Count

@echo off
title Scheduled Task Count
setlocal enabledelayedexpansion

schtasks /query /fo table

echo.
set /a count = 0
for /f %%i in ('schtasks /query /fo table /nh') do (
set /a count = !count! + 1
)

echo Total Tasks Count : !count!
set /p=

Tuesday, February 19, 2013

Restart a server using command prompt

Restart a server using command prompt

Use command:

shutdown -r -f -t0

-r : restart
-f : forcefully
-t : time (Here we have given 0 secs, which means server will be rebooted immediately)

If you dont specify time, default time taken for shutting down is 30 secs.