Powered By Blogger

Wednesday, July 31, 2013

msbuild for Code Analysis and Build/Rebuild Log generation

msbuild.exe commandline can be useful to enable Code Analysis and log the output of visual studio solutions or project files.

Rule set for the code analysis will be same as what developer has set with his proj file/ solution.

eg:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "\SolutionFile.sln" /P:RunCodeAnalysisOnce=True  /t:rebuild     /verbosity:quiet /logger:FileLogger,Microsoft.Build.Engine;logfile="\DebuggedOutPut.log" 

The Log file will give detail information about the CA errors with details and details on Errors and other warnings from Solution file.

Passing parameter to command line option of setup.exe - using VB Script

1.       Installation of setup.exe in silent mode by passing arguments.

How to Run setup.exe in silent>

            strEXE = here & "\setup.exe"
commandline=""& strEXE &" /s “
retVal=wsh.Run(commandline, 1, true )

                How to pass parameters in silent mode installation

                        here = fso.GetParentFolderName(Wscript.ScriptFullName)
wsh.CurrentDirectory = here
INSTALLDIR="\"& chr(34) &"C:\TEST Folder\My Dest\"& chr(34)
REPLACETHIS="\"& chr(34) &"APPNAME_2013_V3\"& chr(34)
REPLACE2="\"& chr(34) &"APPNAME\"& chr(34)
REPLACEDESCR="\"& chr(34) &"Information\"& chr(34)
LogFile ="C:\Test\My Logs\MyTest EXE.log"

strParams = "INSTALLDIR=" & INSTALLDIR & _
                " REPLACETHIS=" & REPLACETHIS &  _
                " REPLACE2=" & REPLACE2 & _
                " REPLACEDESCR=" &REPLACEDESCR& _
                ""
strEXE = here & "\setup.exe"
commandline=""& strEXE &" /s /v""/qb /L*v \"""& LogFile &"\"" " & strParams & "" & chr(34)
retVal=wsh.Run(commandline, 1, true )

msgbox(retVal)

Tuesday, July 30, 2013

Get Character from ASCII value in Batch

cmd /c exit 34
SET strChar= %=exitcodeAscii%
:: reuse strChar
echo %strChar%

List & Drop all Procedures and Tables in a Database

I) List all Stored procedures in a database:

Select * from sys.procedures where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%'

OR

Select * from sys.objects where type='p' and is_ms_shipped=0 and [name] not like 'sp[_]%diagram%'

Please note that I have added the 'NOT LIKE' part to get rid of stored procedures created during database installation.

II) Delete all [user created] Stored procedures in a database:

Select 'Drop Procedure ' + name from sys.procedures Where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%'

This would list down all the user defined Stored procedure as 'Drop Procedure procedureName' in the result pane. Just copy-paste it into the query window and execute it once.


Drop all tables:

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"