Thursday, 23 June 2011

VBScript to delete folder from APPDATA and LocalSettings

set fso =createobject("scripting.filesystemobject")
set wshshell = createobject("wscript.shell")
USRPROFILE = wshshell.expandenvironmentstrings("%APPDATA%")
If fso.FolderExists(USRPROFILE & "\santosh") Then
   fso.DeleteFolder(USRPROFILE & "\santosh")
End If
USRPROFILE = wshshell.expandenvironmentstrings("%HOMEPATH%")
If fso.FolderExists(USRPROFILE & "\Local Settings\Application Data\santosh") Then
   fso.DeleteFolder(USRPROFILE & "\Local Settings\Application Data\santosh")
End If

Wednesday, 22 June 2011

Best Practices for INI files

The inifile table contains the initialization  information that the application needs to set in an .ini file
 
 
Usual ini file issues encountered are:

1)      Ini file contains comments/commented sections
2)      Ini file contains repeated value(s) under the same section
3)      Ini file contains repeated sections
4)      Ini file contains a value or values that are too long for Installshield to handle, results in a clipping of the information
5)      Ini file does not have a section heading

  Ini file contains comments


The ini file in the screenshot above contains commented sections designated by a semi-colon, ‘;’. This is seen as incorrectly formatted by Installshield and is not brought in through the inifile table.

Best Practice:
The best practice in this case is to extract the comment sections from the ini file, and to place them in a new text file with the same name, installed to the same location.

In the case above the sections highlighted in red are removed from bcl.ini and placed in a new file called bcl.txt; this is then installed to the same location as bcl.ini, which can in turn then be installed through the inifile table

     


In the ini file above, there are repeated values under the same section headings.

E.g. In ‘section1’ above, Value=10, Value=20.

This ini file is captured properly and included/represented correctly in the inifile table, but when the application is installed only the first value appears in the ini file:


The values highlighted in red in the first screenshot do not appear in the ini file after installation (see above screenshot) and obviously this is incorrect behavior.

Best Practice:
This is an exception to normal ini file best practice. The ini file in question should be installed through the file table and the customer should be notified to ensure that no previously existing settings are overwritten during installation.

    Ini file contains repeated sections


This is a similar scenario to issue two above, but in this case, there are repeated sections in the ini file.
e.g. In the ini file in the screenshot above, section SameSect appears three times with three different sets of values.

This ini file is captured properly and included/represented correctly in the inifile table, but when the application is installed only the first section appears in the ini file:
.


Only the first appearance of SameSect is installed (see above screenshot) and the sections highlighted in red from the first screenshot do not appear. This is incorrect behavior.


Best Practice:
This is an exception to normal ini file best practice. The ini file in question should be installed through the file table and the customer should be notified to ensure that no settings are overwritten during installation.
  Ini file value(s) too long for the inifile table


In the ini file above, the value EventScript119 (highlighted section), contains too many characters to be handled correctly by Installshield. The entry in the inifile table will be a clipped version (i.e. to as many characters as it can handle) and this will result in information being lost. This is not desired behavior and can even cause Installshield to crash.

Best Practice:
This is an exception to normal ini file best practice. The ini file in question should be installed through the file table and the customer should be notified to ensure that no settings are overwritten during installation.

  Ini file has no section heading


The ini file in the screenshot above has no section heading. This is formatted incorrectly and will not be captured properly by Installshield.

Best Practice:
This will not be put into the inifile table by Installshield during capture and will instead be put into the file table. A file in this format should be left to install through the file table. The customer should be notified in case any entries are overwritten during install.
Ini file contains repeated values

Steps to follow when a package contains selfreg table entry


The SelfReg table contains information about modules that need to be self registered. The installer calls the DllRegisterServer function during installation of the module; it calls DllUnregisterServer during Uninstallation of the module. The installer does not self register EXE files.

Steps to follow when a package contains SelfReg entry:


1.       Look for WiseComcapture.exe under “%ProgramFiles%\Wise Package Studio\Windows Installer Editor\”.
     
       WiseComCapture.exe

2.       The command line for executing this exe is displayed by double clicking it.

 WiseComCaptureUtility

3.       Install the application which has SelfReg table entries and locate the path of the file which is self registered. For e.g., If “MMRClientSrcFilter.dll” has an entry in SelfReg table, locate the path where it gets installed say, “C:\Program Files\VMware\VMware VDM\Client\bin”.
MMRClientSrcFilter.dll
4.       Now use "WiseComCapture.exe" to get the registry entries associated with the .dll file:
WiseComCapture.exe /r " C:\Program Files\VMware\VMware VDM\Client\bin\MMRClientSrcFilter.dll" “C:\MMRClientSrcFilter.reg”

CmdLine


5.       Now the registry entries associated with MMRClientSrcFilter.dll will be captured in “MMRClientSrcFilter.reg” file.
        MMRClientSrcFilter.Reg

EditedReg

6.       Delete the registry entries from "Class" table, "ProgID" Table, "Registry" table, which is associated with ”MMRClientSrcFilter.dll" Component in the package. And also delete the "MMRClientSrcFilter.dll" entry in the SelfReg table.



7.       Import “MMRClientSrcFilter.reg” in the package and when prompted with the below screen, click Yes/No.
Advertisement Info

8.       Continue all the above steps for the other SelfReg entries in the package.

Creating a Package for Driver Installation

To create package for driver installation ,
- Download the Driver
- Extract what you really need
- Create a new package
- Add a Driver Feature to your package
- Adding  DIFxApp merge module to your package
- Adding driver to the package and setting it to install
- Deploying your package
Download the Driver
We'll start by opening our Web browser to Dell's Web site and choosing "Support and Help" - > "Drivers and Downloads". For the computer model, we will choose OptiPlex GX260 and Windows XP.
For this demo we'll use the Network driver called "3Com 3C905C-TXM Ethernet Adaptor" as an example. We will use this one because network drivers tend to be good culprits for extra fluff during their installations. Who cares if we have Intel's gadget for allowing us display statistics or other information about the network card? We just want the NIC to do its job right? The file name we download is R49958.EXE.
Extract what you really need
Next we will execute the downloaded file and it will extract to the folder C:\Dell\Drivers\R49958. Then it automatically launches the setup. Instead of running the setup, we want to click cancel at this screen.
Next we want to explore the folder it created inside of the R49958 folder we see a version.txt file and a folder called Windows. Open the Windows folder we are looking for the INF files for the driver. For this particular driver we find them in the C:\dell\drivers\R49958\Windows\Update\Source folder.
Looking at the .inf  files that are located in that folder we see several files. If you open the W9X90XBC.INF file and look all the way to the bottom of the file you'll see that it says it is the "Installation file for 90x - v5.4.67". This inf file also has sections for Win9x, Windows 2000, and all other Operating systems. This should work for us. Also, at the top we want to note that the catalog file is w9x90xbc.cat. In the inf file it lists el90xBC3.sys, el90xBC5.sys and netdi90x.dll under [SourceDisksFiles]. Using this information we can determine that we need the following files:
W9X90XBC.INF
w9x90xbc.cat
el90xBC3.sy_
el90xBC5.sy_
netdi90x.dl_
Let's copy them to a separate location. Then use the expand command to decompress el90xBC3.sy_ to el90xBC3.sys. Also, use the expand command to decompress netdi90x.dl_ to netdi90x.dll. Do the same for el90xBC5.sy_. You can now delete the files that end with the underscore. Now we have 480kb of Files.
Create a new package
Next we want to create a project where we will create  driver installation. We will rely on some information already gathered to complete these steps. Refer to the version.txt file listed earlier to complete the version info below. Follow these steps to create your project.
  1. Open Wise Package Studio
  2. On the Menu bar Click File -> New project
  3. Project Name: Intel 3C905C-TXM Driver 4.31
    Product Vendor: Intel
    Application Name: Intel 3C905C-TXM Driver
    Package Name: Intel 3C905C-TXM Driver 4.31
    Process: Repackage for Windows Installer (or your preferred package)
  4. Click Close
  5. Click Yes for the warning about a blank Vendor Package
Normally at this point you would capture your package and Edit the package.  Since we are not actually capturing the installation, we have to create our own wsi. In step 1 we do not have a wsi already created with the name of our package, so it will open the last wsi file we used. Follow these steps to create your own WSI file:
  1. Click on the tools tab and double click "Windows Installer Editor".
  2. On the Menu bar Click File -> New
  3. Under predefined templates choose "Device Driver"
  4. Make sure the "Create .WSI or .WSM project file that can be compiled into an .MSI or.MSM" radio box is selected.
  5. Click OK.
  6. On the Menu bar Click File -> Save As
  7. Ensure that you are in the driver project folder and then name the WSI the same as your project name. In this case it is "Intel 3C905C-TXM Driver 4.31.wsi"
From now on when you "Edit package" from the Wise Studio project tab it should open directly into this WSI. If it doesn't then you probably didn't name your wsi the same as your package name. We now have our package ready to put our driver into.
Add a Driver Feature to your package
We have  a standard .wsi file. So we need to create a feature that can be installed. If we want to get fancy, we could have all drivers in their own feature and the user could select which one to install. We're going to stick with a simple package that just installs the driver we downloaded from Dell's website.
  1. Choose the "Installation Expert" tab at the bottom of the Windows Installer Editor.
  1. Under the "Project Definition" Page View Choose "Features".
  2. Click The Complete Feature on the right.
  3. Click Add and then fill the feature details as follows:
    Name: Driver (This could be more descriptive if you were going include multiple drivers)
    Title: Driver
    Check the "Disable advertising if not supported by OS" checkbox.
  1. Click OK
You now have a feature called driver. However we  also need to add a condition to this feature that will only allow us to install a driver for Windows 2000 and above. Follow these steps to add a condition.
  1. Click on the driver feature that you just created.
  2. Click the "Add Condition" button.
  3. In the feature condition box enter "VersionNT >= 500" without the quotes.
Adding this condition will require Windows 2000 or newer to install this feature. We'll see the benefit of this in the next section.
Adding the DIFxApp merge module to your package
Microsoft has released a Driver Installation Framework that allows you to install signed drivers on Windows 2000 and newer operating systems. It is called DIFxApp. This Framework is available as a merge module from Wise. When we create our package we chose the "Device Driver" template so it should have loaded the DIFxApp merge module, but currently Wise forgot to do this for the "Device Driver" Template. It's easy enough to add it ourselves.
  1. Choose the "Installation Expert" tab at he bottom
  2. Under the "Feature Details" Page View Choose "Merge Modules".
  3. Change your "Current feature" to "Driver"
  4. Click Add
    If you see the DIFxApp module in the list skip to step 10 other wise continue to steps 5-9
  5. Click Download
  6. Choose WISE Web site and Click Next
  7. Find the DIFxApp and click the checkbox next to it.
  8. Click next to accept the default target location.
  9. Click Finish
  10. Check the DIFxApp checkbox and click next
  11. Click Next and then Click Finish.
We now have the merge module loaded. This will give us a new details tab called Driver when we add the files in our next section.
Adding and the driver to the package and setting it to install
Now we need to add the driver files that we saved earlier. The order of adding these files is very important. The .inf file should always be added first and by itself. After we add the .inf file we can add the rest of the files as a group.
First we need to add the location we want to install the driver files to and then add the driver files.
  1. Choose the "Installation Expert" tab at the bottom of the Windows Installer Editor.
  2. Under the "Feature Details" page view, choose "Files".
  3. Change your "Current Feature" to VersioNT >= 500
  4. Click "Program Files" in the bottom left windows
  5. Click New and enter Driver for the folder name. It will automatically become your installation directory.
  6. Find the folder your copied the driver files to in the top left window and click on it.
  7. On the right side, click the W9X90XBC.INF file and then click "Add File"
  8. Add the remaining files.
We now have the files in our package, however we need to set the driver to install using the DIFxApp merge module we downloaded earlier
.
  1. Right click on the W9X90XBC.INF file in the bottom right window and choose details.
  2. Click the driver tab. If it is missing you probably didn't load the merge module correctly.
  3. Click the "Use DIFxApp to install this driver file" checkbox.
  4. If you do not want your package to prompt if the hardware is not there, uncheck the "Prompt for missing device" checkbox.
  5. Click OK.
All we have left to do is compile our wsi file and proceed with any other packaging procedures that you would normally follow.
Deploying your package
Next you can run your package manually and click through each screen. If you had multiple drivers that you want to select you could create custom dialogs. If you want to deploy this package silently you could do that by using the /qn switch when you execute the msi.
As long as the driver program is installed, you will have a folder called Driver in your Program Files directory that includes the files from the package. You may or may not want to clean them up. More than likely you would want to point the installation to the Windows\system32\drivers\mydrivers folder instead so that you will always keep them on your PC.
It is also interesting to note that in the add/remove programs you will actually see 2 new items. You will see a program called Driver, and you will also see a program called "Windows Driver Package" that has the details on the driver you installed. Removing the driver program will remove both.
 
Hopefully most drivers you want to install will be signed drivers.

Product Language codes

Language - Country/Region
Code
Afrikaans - South Africa
1078
Albanian - Albania
1052
Amharic - Ethiopia
1118
Arabic - Saudi Arabia
1025
Arabic - Algeria
5121
Arabic - Bahrain
15361
Arabic - Egypt
3073
Arabic - Iraq
2049
Arabic - Jordan
11265
Arabic - Kuwait
13313
Arabic - Lebanon
12289
Arabic - Libya
4097
Arabic - Morocco
6145
Arabic - Oman
8193
Arabic - Qatar
16385
Arabic - Syria
10241
Arabic - Tunisia
7169
Arabic - U.A.E.
14337
Arabic - Yemen
9217
Armenian - Armenia
1067
Assamese
1101
Azeri (Cyrillic)
2092
Azeri (Latin)
1068
Basque
1069
Belarusian
1059
Bengali (India)
1093
Bengali (Bangladesh)
2117
Bosnian (Bosnia/Herzegovina)
5146
Bulgarian
1026
Burmese
1109
Catalan
1027
Cherokee - United States
1116
Chinese - People's Republic of China
2052
Chinese - Singapore
4100
Chinese - Taiwan
1028
Chinese - Hong Kong SAR
3076
Chinese - Macao SAR
5124
Croatian
1050
Croatian (Bosnia/Herzegovina)
4122
Czech
1029
Danish
1030
Divehi
1125
Dutch - Netherlands
1043
Dutch - Belgium
2067
Edo
1126
English - United States
1033
English - United Kingdom
2057
English - Australia
3081
English - Belize
10249
English - Canada
4105
English - Caribbean
9225
English - Hong Kong SAR
15369
English - India
16393
English - Indonesia
14345
English - Ireland
6153
English - Jamaica
8201
English - Malaysia
17417
English - New Zealand
5129
English - Philippines
13321
English - Singapore
18441
English - South Africa
7177
English - Trinidad
11273
English - Zimbabwe
12297
Estonian
1061
Faroese
1080
Farsi
1065
Filipino
1124
Finnish
1035
French - France
1036
French - Belgium
2060
French - Cameroon
11276
French - Canada
3084
French - Democratic Rep. of Congo
9228
French - Cote d'Ivoire
12300
French - Haiti
15372
French - Luxembourg
5132
French - Mali
13324
French - Monaco
6156
French - Morocco
14348
French - North Africa
58380
French - Reunion
8204
French - Senegal
10252
French - Switzerland
4108
French - West Indies
7180
Frisian - Netherlands
1122
Fulfulde - Nigeria
1127
FYRO Macedonian
1071
Gaelic (Ireland)
2108
Gaelic (Scotland)
1084
Galician
1110
Georgian
1079
German - Germany
1031
German - Austria
3079
German - Liechtenstein
5127
German - Luxembourg
4103
German - Switzerland
2055
Greek
1032
Guarani - Paraguay
1140
Gujarati
1095
Hausa - Nigeria
1128
Hawaiian - United States
1141
Hebrew
1037
Hindi
1081
Hungarian
1038
Ibibio - Nigeria
1129
Icelandic
1039
Igbo - Nigeria
1136
Indonesian
1057
Inuktitut
1117
Italian - Italy
1040
Italian - Switzerland
2064
Japanese
1041
Kannada
1099
Kanuri - Nigeria
1137
Kashmiri
2144
Kashmiri (Arabic)
1120
Kazakh
1087
Khmer
1107
Konkani
1111
Korean
1042
Kyrgyz (Cyrillic)
1088
Lao
1108
Latin
1142
Latvian
1062
Lithuanian
1063
Malay - Malaysia
1086
Malay - Brunei Darussalam
2110
Malayalam
1100
Maltese
1082
Manipuri
1112
Maori - New Zealand
1153
Marathi
1102
Mongolian (Cyrillic)
1104
Mongolian (Mongolian)
2128
Nepali
1121
Nepali - India
2145
Norwegian (Bokmål)
1044
Norwegian (Nynorsk)
2068
Oriya
1096
Oromo
1138
Papiamentu
1145
Pashto
1123
Polish
1045
Portuguese - Brazil
1046
Portuguese - Portugal
2070
Punjabi
1094
Punjabi (Pakistan)
2118
Quecha - Bolivia
1131
Quecha - Ecuador
2155
Quecha - Peru
3179
Rhaeto-Romanic
1047
Romanian
1048
Romanian - Moldava
2072
Russian
1049
Russian - Moldava
2073
Sami (Lappish)
1083
Sanskrit
1103
Sepedi
1132
Serbian (Cyrillic)
3098
Serbian (Latin)
2074
Sindhi - India
1113
Sindhi - Pakistan
2137
Sinhalese - Sri Lanka
1115
Slovak
1051
Slovenian
1060
Somali
1143
Sorbian
1070
Spanish - Spain (Modern Sort)
3082
Spanish - Spain (Traditional Sort)
1034
Spanish - Argentina
11274
Spanish - Bolivia
16394
Spanish - Chile
13322
Spanish - Colombia
9226
Spanish - Costa Rica
5130
Spanish - Dominican Republic
7178
Spanish - Ecuador
12298
Spanish - El Salvador
17418
Spanish - Guatemala
4106
Spanish - Honduras
18442
Spanish - Latin America
22538
Spanish - Mexico
2058
Spanish - Nicaragua
19466
Spanish - Panama
6154
Spanish - Paraguay
15370
Spanish - Peru
10250
Spanish - Puerto Rico
20490
Spanish - United States
21514
Spanish - Uruguay
14346
Spanish - Venezuela
8202
Sutu
1072
Swahili
1089
Swedish
1053
Swedish - Finland
2077
Syriac
1114
Tajik
1064
Tamazight (Arabic)
1119
Tamazight (Latin)
2143
Tamil
1097
Tatar
1092
Telugu
1098
Thai
1054
Tibetan - Bhutan
2129
Tibetan - People's Republic of China
1105
Tigrigna - Eritrea
2163
Tigrigna - Ethiopia
1139
Tsonga
1073
Tswana
1074
Turkish
1055
Turkmen
1090
Uighur - China
1152
Ukrainian
1058
Urdu
1056
Urdu - India
2080
Uzbek (Cyrillic)
2115
Uzbek (Latin)
1091
Venda
1075
Vietnamese
1066
Welsh
1106
Xhosa
1076
Yi
1144
Yiddish
1085
Yoruba
1130
Zulu
1077
HID (Human Interface Device)
1279