Thursday, April 14, 2011

FAQS 1 : MSI Packaging & Re-packaging.

Custom Actions
1. How to add custom actions to run only during patching
Add "PATCH" To condition in custom action
2. Name few best practices for creating a Custom Actions
* Do not use custom actions in your package that require elevated privileges to run.

3. 
MISC
1. Which runs first "Run" key or Active Setup
Applications launched by Active Setup will run first. Activesetup is using to configure the userprofile settings if no entry points exists in the package and this will be running only once for a specific user.
Where as RUN key will execute everytime when user login the machine. These settings are configured with different sequence , in order to speedup to get access to windows desktop\user level settings.
2. If you extract a COM information through registering the dll or OCX file which tables will it be reflected

3 Can you elaborate the driver handling via device driver?

4 Apart from APP search what tables you use to find whether the particular application is installed via MSI tables?

5. What is the meaning of Launch condition Office2007
Only proceed the installation if value of "Office2007" property is less then "office2003" property
6. What are the attributes you set for files going under c:\Winnt\System?
Nothing, we will let Windows default file setting to be propagated to the newly added files also.

7. What happens if non-keypath file is deleted and a shortcut is launched.
Nothing Happens,
MSI SDK
1. How many tables can control the flow of Installer. Name them

6 tables,Names of them are InstallExecuteSequence, InstallUISequence, AdminExecuteSequence, AdminUISequence, AdvtExecuteSequence, AdvtUISequence
2. During typical execution how many of them are used.
Only 2 tables are used during any typical execution
MSI Sequence
1. Can we control Uninstall GUI
No.
MSI >=4.5
1. What is Per User Application (PUA)
An application capable of being installed, updated, run and removed by a standard user without elevation is called a PUA
2. What is the minimum OS on which MSI 5.0 will get installed
Windows 2008 and Windows 7
3. What is single package authoring / dual purpose package
A dual purpose package is a windows installer 5.0 package that has been authored to be capable of installing an application in either the per-user or per-machine installation context.
4. What is the limitation of PUA/DPP

Wednesday, April 13, 2011

FreeBasic : Code : runas in FreeBasic

#Include "windows.bi"
#inclib "advapi32"

Declare FUNCTION CreateProcessWithLogonW LIB "ADVAPI32" ALIAS "CreateProcessWithLogonW" ( _
    byval lpUsername As LPCWSTR  , _
BYVAL lpDomain AS LPCWSTR , _
BYVAL lpPassword AS LPCWSTR, _
BYVAL dwLogonFlags AS DWORD, _
BYVAL lpApplicationName AS LPCWSTR , _
BYVAL lpCommandLine AS LPCWSTR , _
BYVAL dwCreationFlags AS DWORD, _
BYVAL lpEnvironment AS DWORD, _
BYVAL lpCurrentDirectory AS LPCWSTR , _
lpStartupInfo AS STARTUPINFO, _
lpProcessInfo AS PROCESS_INFORMATION) AS LONG


Const X_CJ_LOGON_WITH_PROFILE=1
Const X_CJ_CREATE_DEFAULT_ERROR_MODE = &H04000000
'#############################################
'                   RunAsUser for Windows 2000 and Later
'#############################################

FUNCTION RunAsUser(BYVAL UserName AS STRING, _
        BYVAL Password AS STRING, _
        BYVAL DomainName AS STRING, _
        BYVAL CommandLine AS STRING, _
        BYVAL CurrentDirectory AS STRING) AS boolean       

    Dim si AS STARTUPINFO   
    Dim pi AS PROCESS_INFORMATION

    Dim AS String wCurrentDir,wCommandLine,wPassword,wUser,wDomain
    dim R01 AS LONG
   
    si.cb = LEN(si)
   
    wUser = UserName
    wDomain = DomainName
    wPassword = Password
    wCommandLine = CommandLine
    wCurrentDir = CurrentDirectory
     'Print wCommandLine & "TEST"
    R01 = CreateProcessWithLogonW(wUser,wDomain,wPassword, _
        X_CJ_LOGON_WITH_PROFILE, 0&, wCommandLine, _
        X_CJ_CREATE_DEFAULT_ERROR_MODE, 0&, wCurrentDir, si, pi)   
    IF R01 <> 0 THEN
      CloseHandle pi.hThread
      CloseHandle pi.hProcess     
      Return TRUE
    ELSE
      Return FALSE
    END If
End FUNCTION

Dim As Long R01
Dim As String  user_name,password,domain,program,workingDir

user_name="username"
password="pa$$word"
domain="domain"
program="C:\\windows\\notepad.exe"
workingDir="C:\\windows"

R01=RunAsUser(user_name,password,domain,program,workingDir)
 

Tuesday, April 12, 2011

Checking if any process is running using FreeBasic


#include once "windows.bi"               'in
#define UNICODE                          'this
#include once "disphelper/disphelper.bi" 'order
'

Function checkProcName(processName As String) As Boolean
dim as HRESULT hres
dim as zstring ptr procID,procPath, procName

DISPATCH_OBJ(wmiSvc)
DISPATCH_OBJ(colProc)
dhInitialize(TRUE)

hres=dhGetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2",NULL,@wmiSvc)
hres=dhGetValue("%o",@colProc,wmiSvc,".ExecQuery(%s)","Select * from Win32_Process Where Name='" & processName & "'") ' where Name=\'" & "notepad.exe" & "\'")
'
Dim  count  As Integer
count = 0
FOR_EACH0(objProc,colProc,NULL)
  count = count +1
  *procPath=""
  hres=dhGetValue("%s",@procPath,objProc,".ExecutablePath")
  hres=dhGetValue("%s",@procID,objProc,".ProcessID")
  hres=dhGetValue("%s",@procName,objProc,".Name")
   '
   if hres=0 then
       print *procID; tab(8);*procName
   end if
   '
NEXT_(objProc)
Print count
SAFE_RELEASE(wmiSvc)
SAFE_RELEASE(colProc)
dhUninitialize(TRUE)

If count = 0 Then
Return FALSE
Else
Return TRUE
EndIf
End Function


Dim test As Boolean
test= checkProcName("notepad.exe")
print:print "Sleeping to Exit.." & test
Sleep

Monday, April 11, 2011

FAQ's MSI Packaging & Repackaging

There are two version of the document. I have tried my best to have correct information and if you find any issue or wrong information then please inform me about it. The download location for them are as follows