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.

Tuesday, January 1, 2013

Taking site backup in MOSS 2007 using stsadm

Taking complete site backup in MOSS 2007 using stsadm command on cmd:

1) First go to the path using command prompt:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN

2) Fire the command:
stsadm -o backup -url http://sharepoint:8888 -filename c:/filename.dat

Note:
1) This backup only contains Sharepoint related stuff (i.e Config DB, Content DB, Sharepoint Site Pages)
2) If there are any custom pages that are available outside sharepoint, then those pages needs to be incorporated manually.
3) Also if there are some databases(like aspnetdb or custom DB) other than the sharepoint related databases then those databases needs to be restored separately.



Wednesday, November 28, 2012

Unable to restore database in SQL Server because of running processes

Unable to restore database in SQL Server because of running processes.

If you are unable to restore database in SQL Server because of running processes.

1. You can find which processes are running using the following command:
sp_who2

2. After finding out which processes are running relating to the particular database, you can kill them using the kill command with process id

For eg.

kill 63
kill 55

This should restore your database.


Thursday, November 15, 2012

Delete duplicate rows in table with no key in SQL Server

Delete duplicate rows in table with no key in SQL Server:

DELETE
FROM  TableName
WHERE TableName.%%physloc%%
      NOT IN (SELECT MIN(b.%%physloc%%)
              FROM TableName b
              GROUP BY b.ColumnName)