Tuesday, July 17, 2012

VBScript to Find and Replace

I have been using this script for some time now. I took inputs from some sites to create this VBScript. I have modified it to my needs. I want to share this and keep it gfor my reference for future use as well.
I am searching for a text and replacing it with the User input of mail id.

'Use the below function if you want it to run from commandline and take input from users.
'If WScript.Arguments.Count <> 2 then
'  WScript.Echo "usage: Find_And_replace.vbs filename word_to_find replace_with "
'  WScript.Quit
'end If
MailID=InputBox("Please enter your E-Mail ID")
Set oshell=CreateObject("Wscript.shell")
TargetFile= prog & "\App\config.ini"
TempFile= prog & "\App\config1.ini"
FindAndReplace TargetFile, sFind, MailID
WScript.Echo "Operation Complete"

function FindAndReplace(strFile, strFind, strReplace)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objInputFile = objFSO.OpenTextFile(strFile,1)
    'strTempDir = objFSO.GetSpecialFolder(2)
    Set objTempFile = objFSO.OpenTextFile(TempFile,2,true)
    do until objInputFile.AtEndOfStream
        objTempFile.WriteLine(Replace(objInputFile.ReadLine, strFind, strReplace))
    Set objInputFile = Nothing
    Set objTempFile = Nothing
    objFSO.DeleteFile strFile, true
    objFSO.MoveFile TempFile, strFile
    Set objFSO = Nothing
end function 

You can modify this script based on your needs and use it.

Tuesday, July 10, 2012

Internal Consistency Evaluators

This is some material on ICE which I got some time back from AngelD and wanted to post here for my and everyone's reference.

CASE 1: File: 'Red_File' cannot be the key file for Component: 'Blue'. The file belongs to Component: 'Red'
Search for the component name in all the other tables in the following order:
• If the component name is found in the Files Table, then set the keypath for the Component to be the name of the first column in the file table.
• If the component name is found in the Registry Table then set the keypath for the Component to be the name of the first column in the Registry table, and add 4 to the Attributes column.
• If the component name is not found in either table, leave the keypath blank
CASE 2: ' Red_Key' cannot be the key registry key for Component: 'Blue'. The RegKey belongs to Component: 'Red'
Search for the component name in all the other tables in the following order:
• If the component name is found in the Registry Table then set the keypath for the Component to be the name of the first column in the Registry table
• If the component name is found in the Files Table, then set the keypath for the Component to be the name of the first column in the file table, and subtract 4 from the Attributes column.
• If the component name is not found in either table, leave the keypath blank

CASE 1: String overflow (greater than length permitted in column):
This validation error will not cause the installation to behave adversely. The help file says “that the installer does not internally limit the column width to the specified value.”
This error can be removed by using ShortFile Names. This should be removed when it can be.

CASE 2: Value not a member of the set:
ICE03 ERROR Value not a member of the set; Table: Feature, Column: Attributes, Key(s): MirrorTask

The validation is complaining that the value 40 not a member of the set allowed in the Attributes column of the Feature Table.
The values that are allowed in this column are defined in the _Validation Table, shown below.

This says that only the numbers 0,1,2,4,5,6,8,9,10,16,17,18,20,21,22,24,25,26,32,33,34,36,37,38,48,49,50,52,53 and 54 are allowed in the Attributes field.
Looking at the help page for the Feature Table the value of 40 is unacceptable, since it represents 8+32, which are not allowed in combination.
The help page says “Do not use msidbFeatureAttributesNoUnsupportedAdvertise (32) with msidbFeatureAttributesDisallowAdvertise (8).”
Change the Attribute column of the Feature table to 16/48

CASE 3: Not a valid foreign key; Table: ProgId, Column: Class_, Key(s): Notes.NotesUIWorkspace

Go to the ProgID table find the row that refers to Notes.NotesUIWorkspace and take note of the CLSID value. Once this has been noted, check the CLSID column in the Class_ table. This value was found to be missing, so copy the value and place it into the CLSID column of the Class_ table and fill in the rest of the information. To find out if its Context is LocalServer or LocalServer32 etc. you can look up the Registry in the Installation Expert. For this particular case Notes.NotesUIWorkspace had both LocalServer and LocalServer32 so the row had to be repeated but with this two different values in the Context column.

'MTEXTRA.TTF' is a Font and must be installed to the FontsFolder. Current Install Directory: 'OfficeEquationFolder'
Fonts should be only ever installed into c:\windows\fonts.
This error is caused by fonts being installed elsewhere.
Locate the file in the file table and note the name of the component that it is in.

Here the Component is called Global_Office_EquationEditor
Locate that component in the Component Table

Make a new component in step 2, but based on the component changing the Directory_ to FontsFolder (making sure that FontsFolder is defined in the Directory Table)

Component: ICE07Fix1
ComponentId: {GUID} --this needs to be generated. Create a project in Developer, when you add a new component it generates a code that you can use here
Directory_: FontFolder
Attributes: 8
Condition: --copy this from the component that you are fixing
Keypath: --This is the name of the font filename
Move the file into this new component

Change the Component_ column to point to ICE07Fix1
Associate the new component with the existing component’s feature
Find the component that caused the error in the FeatureComponents table and add the new component to the same feature

This error is acceptable
Explanation of error:
“ICE09 validates that the permanent bit is set for every component marked for installation into the SystemFolder. ICE09 posts a warning because you should avoid installing non-permanent system components to the SystemFolder.”
ICE18 ERROR KeyPath for Component: 'MirrorTask' is Directory: 'INSTALLDIR'.
The Directory/Component pair must be listed in the CreateFolders table
This error message only occurs when you have a component that does not contain files, registry keys or ODBC DSNs.
It is easily solved as the ICE message tells you what to do.
Add a row in the CreateFolders Table to create the directory

This also occurs when you have a registry keypath and you have set the directory to INSTALLDIR. The best way to solve this error is simply go to Component table and change the directory to TARGETDIR. This will solve the ICE Error. No need to make any extra Create Folder.

Shortcut: 'Blah' advertises component: 'ComponentBlah'. This component cannot be advertised because the KeyPath type disallows it.
This error indicates that the shortcut is in the wrong component. The shortcut should be in the same component as the file it refers to.
Step1: Find the file that the shortcut is pointing to

The Target column indicates the File key that the shortcut refers to. Here it is a Formatted text string
Step 2: Find the Component that the file is in

Here the File DTPhones.exe is in a component of the same name
Step3: Move the shortcut into the correct component
Correct the Component_ column of the Shortcut

ERROR: The target file 'LONGFI~1.EXElongfilename1.exe' is installed in 'TARGETDIR\PRODUCT' by two different components on an SFN system: 'Component1' and 'Component2'. This breaks component reference counting.
Look at the two files in orca. Sometimes the install compiler makes errors when generating short file names. E.g.
In this situation it has generated the same short file name for two different files.
To remove the validation error, simply give one of the files a new short file name
WARNING Reg key …… is used in an unsupported way. ProgId should be registered via the ProgId table. This entry may overwrite a value created through that table
ICE33 processes entries in the Registry table and may issue a warning for each table entry that registers Classes, Filename Extensions, ProgIDs, Shell Verbs, Remote Server AppIDs, MIME types, or Typelibs.
Though every site you go to will tell you that ICE33 can be ignored, but for the best results, we should remove them if possible. It is not that hard to remove them. Just check the component for which ICE Error is coming. Do rescan advertising for that component and it will put the values in the correct table. Still if you are getting some errors then you can check if the registry still contains the information which is already added to advertising, then you can remove those registries. This will eliminate ICE errors. And even after this if you are getting ICE33 then you can leave them as is in the package.

Icon Bloat. Icon BlahIcon is not used in the Class, Shortcut, or ProgID table. This adversely affects performance.
This ICE checks that all icons that are in the icon table have been used in other tables.
If you have this ICE then you should do a manual search of all the tables to see if there are any references to the icon (e.g. ARPPRODUCTICON often references it). If nothing references the icon then it is safe to delete.

ICE38 ERROR Component Network_Associates installs to user profile.
It must use a registry key under HKCU as its KeyPath, not a file or directory
Create an arbitrary registry key in HKEY_CURRENT_USER and set it as the keypath.
• Add 4 to the Attributes column
• Set the KeyPath to the name of your registry key


Extension rc1 references feature complete and component r1win.exe, but the that component is not associated with that feature in the FeatureComponents table.

Change the entry in the Feature_ column of the Extension table entry to reference a feature that installs the component listed in the Component_ column or change the feature and component associated in the FeatureComponents table

ERROR Component mcstvbi.exe has non-advertised shortcuts.
It should use a registry key under HKCU as its KeyPath, not a file
Make the shortcut advertised. This will have the added advantage of putting self-repair functionality into it.
Checks for directories that are hard-coded to local paths in the Property Table.
Do not hard-code directory paths to local drives because computers differ in the setup of the local drive. This practice may be acceptable if deploying an application to a large number of computers on which the relevant portions of the drives are all the same.
ICE48 posts an error message if there is a directory that is hard-coded to a local path in the Property table.
ICE48 would report the following warning for the example shown.
Directory 'Dir1' appears to be hardcoded in the property table to a local drive.
Directory Table (partial)

Property Table (partial)

If an application has a directory named group in its file structure, then this will clash with the entry GROUP in the property table

A permanent solution to prevent this from happing again is to change the GROUP property to a non dictionary word, and therefore avoid this potential clash in the future.

ERROR Component 'HKCU' has both per-user and per-machine data with a per-machine KeyPath.
1. Create a new component for this (and any other) key that needs to be separated
2. Move the registry key into this new component
3. Associate the new component with the existing component’s feature
The file File1 is Versioned. It cannot be hashed
This error is acceptable as the hash table will not be read for the file in question.
You could remove the row from the hash table to remove the error.
The file File1 is a font, its language should be null.
To correct this you should delete anything that is in the language column for the file
ERROR: The directory INTERNET_EXPLORER is in the user profile but is not listed in the RemoveFile table.

Put the directory INTERNET_EXPLORER in the RemoveFile table.

ICE69 Mismatched component reference. Entry 'DTPhones.exe' of the Shortcut table belongs to component 'ProgramMenuFolder'. However, the formatted string in column 'Target' references file 'DTPhones.exe' which belongs to component 'DTPhones.exe'. Components are in the same feature.
This means that the Target file is not in the component in the Component_ column
Change the Target field to equal the name of the feature that the component is in. You will have to look at the FeatureComponents table to find this out.

This action SetOEM_NOCOST has duplicate sequence number 11 in the table InstallExecuteSequence
In a third party MSI, this error should not be a problem because we can assume that the MSI has been tested and the order that the actions fire is good enough
Action 'FileCost' found in InstallExecuteSequence table is a required action with a condition.
In Microsoft MSIs it is quite common for the package to reboot and they condition their actions so that only some get rerun after the reboot
In this situation, the error is acceptable
WARNING Property `AdminUser` found in …... `Privileged` property is often more appropriate.
The AdminUser property is true if the logged in user is the Administrator, Privileged is true for powerusers too.
It is easy to remove the error message. Simply replace the word AdminUser with Privileged.
In the IniFile table entry (IniFile=) PPTCast04 the DirProperty= is not found in Directory/Property/AppSearch/CA-Type51 tables and it is not one of the installer properties
This ice checks that the DirProperty column of the Inifile table is valid. This is intended to check that the ini file changes are made in a valid folder.
Unfortunately this check is not always valid because the help file says “If this field is left blank, the .ini file is created in the folder having the full path specified by the WindowsFolder property.”
If the field is blank and you are happy that the ini file changes should be made in the WindowsFolder, then this error is acceptable

Thursday, July 05, 2012

Creating a Device driver based package in Installshield

It is very easy and simle to create a device driver based application from Installshield.
I am using Installshield 2012.

You need to make sure that the driver is a signed driver. If the driver is not signed, then you need to sign the driver first. It is good to have your driver signed, but you can install and unsigned driver as well. Check an option later.

Go to Installshield Wizard in Installation Designer and click on Project button on top an then Device Driver wizard.

Click Next ->

Select the path to your .inf file on your machine. Choose the system architecture. I am choosing x64 as I am packaging for 64 bit machines.

Click Next-> Next->

Select the options as per your requirement. I have chosen the above ones.

Click Next->

Click Next->

You will get the summary and then click on Finish.

It will add the settings in your component of INF file.

Hope this helps you create device driver easily with Installshield.