Saturday, August 8, 2009

Compare SQL Databases

If you ever come across a situation where your application behaves differently with different DBs you have and not sure if any of the Stored procedures have changed...?
Following SQL script can be used to compare the Stored procedures.
select top SYSCOM_1.text, DB2.text 
from MyDATABASE_1.dbo.syscomments SYSCOM_1 
inner join 
sysobjects so on so.id=SYSCOM_1.id inner join 
(select SYSCOM_2.text,SYSCOM_2.id, so.name from MyDATABASE_2.dbo.syscomments SYSCOM_2inner join MyDATABASE_2.dbo.sysobjects so on so.id=SYSCOM_1.id )
DB2 on so.name = DB2.name COLLATE DATABASE_DEFAULT 
where DB2.text <> SYSCOM_1.text COLLATE DATABASE_DEFAULT

Tuesday, August 4, 2009

Security update for Microsoft Visual Studio 2005

On July 28th, MS rolled out a security upgrade for MS Runtime files. If you haven't built your c++ project from last few day, you have a surprise waiting.

Welcome to the world of Manifest Hell!!!. Soon your eventviewer will be filled with SideBySide error. If you haven't rebuilt of your binaries completely, you will end up getting two entries in your binary manifest. If your test machine is not updated with latest windows updates, your application will not launch at all. You need to update have the runtime binary with newer Runtime.

So here is what you need to do if you are getting SideBySide error.

Open the manifest file(Or the Binary if you are embedding the manifest). See if it has two entries for dependency..













8.0.50727.4053 is the new version after the upgrade.

rebuild all the Dependant projects, so that all are using the newer runtime. In all cases make sure you have only one dependency, if there are more look for its dependency and rebuild'em.

Yes, its simple. Just rebuild.

Finally, Make sure you package right redistributable installer in the final installer.
Posted by Picasa

Thursday, June 25, 2009

MSP - Patching rules

If you create a new version of your program and want to be able to update existing installations either with a full install package or with a patch package, you must follow some rules. Breaking these rules will cause strange effects like previously installed features appearing as advertised after the update, or files not getting updated features not getting installed etc. If you are not following them, you can expect your MSP to lead you no where :)

Some rules small and minor updates : 

  1. Follow the rules for changing or keeping the ProductCode, ProductVersion and UpgradeCode, depending of the type of update you are creating. 
  2. Always change the package code.
  3. Do not move componentes to other features.
  4. Do not move sub features. You can add new features and sub features.
  5. You can add components to existing features. If you want to add a new feature you can synchronize the installation state of a new child feature with its parent feature by setting its Remote Installation property to "Favor Parent" and its Required property to yes.
  6. Do not change component codes.
  7. Do not change the name of the key file of a component.
  8. You can modify the contents of a component (add, remove or modify files, registry keys and shortcuts), but only if that component is not shared across features.
  9. If you remove a file or registry key from a component, you must populate the RemoveFile or RemoveRegistry table respectively to delete the orphaned resource.
  10. Do not change the name of the .msi file.

Ref: Stefan Krueger@http://www.installsite.org/pages/en/msi/updates.htm


Wednesday, June 17, 2009

MultiLanguage Patch - MSP


If you are thinking about some command for MSI installer to do so, there is'nt any. What we are going to implement is a Hack where we can deploy the langauage transforms before applying the patch.

How we are going to do this is
1) Get MST files from the Installshield build output folder
2) Create a Package using NullSoft Installer( its easy)
3) Write code in nullsoft to replace the MST file locally
4) Extract the update.exe or MSP and run

Original MST file is stored in C:\WINDOWS\Installer\{PROD_CODE}\1031.MST, you can find out the path by reading HKLM\SOFTWARE\Classes\Installer\Products\MY.PROD.GUID and value of transforms key. Now you can go and replace this file and run the patch. Below is the code for doing this. Use NSIS compiler to compile it.

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_VERSION "3.3"
!define PRODUCT_PUBLISHER "ItsMe"
!define PRODUCT_WEB_SITE "http://www.MySite.com"

; MUI 1.67 compatible ------
!include "MUI.nsh"


!define MUI_ICON "Developer.ico"

;
; Language files
!insertmacro MUI_LANGUAGE "English"



SetCompress auto
OutFile "Patch.exe"
Function .onInit

SetSilent silent

FunctionEnd


Section "MainSection" SEC01
SetOutPath "$tempdir"
SetOverwrite ifnewer
File "D:\Build Output\Patch\Update.exe"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1031.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1032.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1033.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1034.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1036.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1041.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1040.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1043.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1046.mst"

ReadRegStr $0 HKLM "SOFTWARE\Classes\Installer\Products\MY.PROD.GUID" "transforms"

; remove
StrCpy $1 $0 "" -8

Rename $0 "$0.bak"
CopyFiles $tempdir\$1 $0

exec "$tempdir\Update.exe"
SectionEnd

Section -AdditionalIcons
SectionEnd

Section -Post
SectionEnd

Wednesday, May 27, 2009

How to disable Symantec Device Manager and access your disabled USB drive

Well, its going to be interesting! Symantec might be installed on your office machine and its controlled by policy, so it might be blocking you from connecting any USB device. You can enable it at your own risk, provided your are a machine admin.

open services.msc and look for Symantec Management Client Service.
Go to properties.
Open the logon tab.
Give your current network credentials.
Now go to Task Manger and kill smc.exe.

Now on Symantec will be running in your account and you are the boss. You can Stop/Start/Kill it at any time.

If you dont want to see the service running again, dont give your right password in logon. Service wouldnt start now on, because of the logon failure.

Disclaimer: I am not using the above method, neither i am recommending this to you. You are on your own buddy!
Posted by Picasa

Tuesday, May 26, 2009

Read contacts from Outlook using javascript


Following Javascript uses MAPI component and reads the contact details stored in Outlook. This works only with Outlook, not with Outlook express. It can also read the GAB if outlook is connected(following code does not do that, it prints only the addresses stored. You can remove the check for 'Contacts' to do so..).


 
<html><head>
<script language="javascript">
<!---
function readOutlookContacts()
{
obj = new ActiveXObject("Outlook.Application");
mapi= obj.GetNamespace("MAPI");
if( mapi )
{
addlst = mapi.AddressLists;
if( addlst )
{
if( addlst.count > 0 )
{
for(i = 1; i <= addlst.Count;i )
{
al = addlst.Item(i);
addentrs = al.AddressEntries;
if(al.name=="Contacts") //no need to read GA Book or other folders
{
for( tmpi = 1; tmpi <= addentrs.Count; tmpi )
{
aentry = addentrs.Item(tmpi);
email =aentry.Address;
document.write(":" +email + <br>);
}}}}
}}
}
-->
</script>
</head>
<body onLoad=javascript:readOutlookContacts()>
</body>
</html>


But take care of IE security settings for activex while running this.

Monday, May 25, 2009

Patch Installation


If you are creating a patch using installshield, you can either create an update.exe or a MSP file. Advantage of creating MSP is that; you can open it in ORCA and see the difference the patch brings out.

But be careful !!!

Never run the MSP by double clicking on it. It will trouble you for sure, you might see some features getting added automatically. You might see a new feature getting installed through patch. You will find a ADDLOCAL = newfeature getting joined to the installation in the MSI install log.

To avoid always use following command for applying the patch.

msiexec.exe /p "\Patch.msp" REINSTALL=ALL REINSTALLMODE=omus

My advice will be is to create Update.exe always if you ever need a MSP you can extract it. So, if you need a MSP out of update.exe; run the exe and search for the msp in temp folder when you are at the PatchWelcome screen.