Blog Home 
Todd Myhre

RSS 2.0 Atom 1.0 CDF  
 
Sign In
 
 Friday, April 27, 2007

I wanted to add some information to an install log file about the system that I was installing on.  I created a separate Log function that can be called from anywhere in the script.  It has been very valuable when an install happens in production and there are issues.  I added a Log function call to the beginning and end of each function in my script, so I know when the function is being called.

I also added a function to get the computer name.

The creation of the InstallLog.txt file takes place in the OnBegin function with the following code:

 // Create a log file on the C drive so that
 // the install can log information to it. This is a convenient
 // location for tech support to find it.
 OpenFileMode(FILE_MODE_APPEND);
 CreateFile(g_LogFileHandle, "C:\\", "InstallLog.txt");
 Log("--Start - OnBegin()");   
 Log("Begin Log File");
......

// Write information to the InstallLog.txt file
function Log(strInfo)
 NUMBER   nvResult;
 STRING   svResult;
begin
 GetSystemInfo (TIME, nvResult, svResult);
 strInfo = svResult + " : " + strInfo;
 WriteLine(g_LogFileHandle, strInfo);
end;

......

//Send system information to log file
function LogSystemInfo()
 STRING svComputerName, svDate, svOS, svOSSP, svWinMajor, svWinMinor;
 NUMBER nvDate, nvOS, nvOSSP, nWinMajor, nWinMinor;
begin
 Log("--Start - LogSystemInfo()");                            
 //log date
 GetSystemInfo (DATE, nvDate, svDate);
 Log("Date of Install = " + svDate);
 
 //log computer name
 svComputerName = GetComputerName(); 
 Log("Computer Name = " + svComputerName);
 
 // Get the operating system.
 nvOS = SYSINFO.nISOSL;
    switch (nvOS)
        case ISOSL_WIN2000:
            svOS = "Windows 2000";
        case ISOSL_WINXP:
            svOS = "Windows XP";
        case ISOSL_WINSERVER2003:
         svOS = "Windows 2003 Server";
        case ISOSL_WINVISTA:
         svOS = "Windows Vista";
        default:
         svOS = "Invalid OS";
    endswitch;
    Log("Operating System = " + svOS);
   
    //get windows major version
    nWinMajor = SYSINFO.nWinMajor;
    NumToStr(svWinMajor, nWinMajor);
    Log("OS Major Version = " + svWinMajor);

    //get windows minor version
    nWinMinor = SYSINFO.nWinMinor;
    NumToStr(svWinMinor, nWinMinor);
    Log("OS Minor Version = " + svWinMinor);

    //get operating system service pack
    nvOSSP = SYSINFO.WINNT.nServicePack;
    NumToStr(svOSSP, nvOSSP);
    Log("OS Service Pack = " + svOSSP);
    Log("--End - LogSystemInfo()");                            
end;

....

//get the name of the computer we are installing on
function string GetComputerName()
 string szKey, szName, svValue;
 number nvSize, nvType;

begin
  szKey = "System\\CurrentControlSet\\Control\\ComputerName\\ComputerName";
  szName = "ComputerName";

  // Set the default root.
  RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

  // Retrieve the registry key value.
  RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize);
  return svValue;
end;

4/27/2007 8:48:13 AM (Central Standard Time, UTC-06:00)  #    Comments [0]   Installshield | Logs  |  Trackback
 Monday, April 23, 2007

I needed a way to add a program to the Vista Firewall Exception List programmatically during an Installshield 12 install.  After searching the Internet, I found that NETSH is the command to user and here is the solution I implemented.

#define NETSH_COMMAND WINSYSDIR^"NETSH.EXE"

prototype AddFirewallException();

function AddFirewallException()
 STRING szParams, szInstallDir;
begin 
  //add dbsrv7.exe to Firewall Exception List
  szInstallDir = INSTALLDIR;
  szParams = "firewall add allowedprogram program=\" C:\Test\dbsrv7.exe\" name=\"ASANYServer\" mode=enable";
  SdShowMsg("Adding ASANYServer to Firewall Exceptions List", TRUE);
  LaunchAppAndWait(NETSH_COMMAND, szParams, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN);
  SdShowMsg("Adding ASANYServer to Firewall Exceptions List", FALSE);
end;  

4/23/2007 8:01:32 AM (Central Standard Time, UTC-06:00)  #    Comments [1]   Firewall | Installshield | Vista  |  Trackback
 Friday, April 20, 2007

I have been working on an Installshield 12 project that requires a share to be created and specific directory permissions for that share in order for the installed code to work.  Below is the code I used to give the Users group Full share permissions and the Users group Change directory permissions.  This code is for Windows 2003 Server or Vista.  XP automatically provides full access to the share and directory.

#define NET_COMMAND WINSYSDIR^"NET.EXE" 
#define CACLS_COMMAND WINSYSDIR^"CMD.EXE"

export prototype CreateShareDirectoryPermissions();
function CreateShareDirectoryPermissions() 
   STRING szParams, szInstallDir, szDirPerm;

begin

  // Create a share  
  szInstallDir = INSTALLDIR;
  StrRemoveLastSlash(szInstallDir);
  //if Windows Server 2003 or Vista then grant full permissions to Users group
  if(SYSINFO.WINNT.bWinServer2003 || SYSINFO.nISOSL == ISOSL_WINVISTA) then  
      //also need to make sure we have directory permissions
      szDirPerm = "/c CACLS \"" + szInstallDir + "\" /T /E /G USERS:C";
      SdShowMsg("Updating direcotry permissions for share to database", TRUE);
      LaunchAppAndWait(CACLS_COMMAND, szDirPerm, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN);
      SdShowMsg("Updating direcotry permissions for share to database", FALSE);

      //Create share parameters
      szParams = "SHARE CImaxDN=\"" + szInstallDir + "\" /GRANT:USERS,FULL";
  else
      szParams = "SHARE CImaxDN=\"" + szInstallDir + "\"";
  endif;
  
  Log("Creating network share: " + NET_COMMAND + " " + szParams);
  SdShowMsg("Creating network share to database", TRUE);
  LaunchAppAndWait(NET_COMMAND, szParams, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN);
  SdShowMsg("Creating network share to database", FALSE);

end;

4/20/2007 8:21:26 AM (Central Standard Time, UTC-06:00)  #    Comments [0]   Installshield | Vista | Windows 2003  |  Trackback
 Thursday, April 19, 2007

I have a customer that was using a custom application on their Symbol 8146(Pocket PC 2003) device.  At night the device was cradled with the application still active.  In the morning when the user returned to use the 8146, the Start screen was always displayed and their application was running in the background.  The customer found this unacceptable.

Windows Pocket PC 2003 has an option to configure the 'Display Today screen if device is not used for xx hours' option.  Of course I could go  to the Start - Settings - Today screen to disable it, but I wanted to find the registry setting do disable it so I could create a registry file for deployment. 

After scouring the registry settings, nothing stood out.  I finally found the fix below:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shell\Rai]
"SessionTimeout"=dword:00000000

This value represents the number of hours of inactivity until the display goes back to the Today screen. The default value is "SessionTimeout"=dword:00000004.
A value of "SessionTimeout"=dword:00000000 (as above) prevents the Today screen from displaying.

4/19/2007 9:22:01 AM (Central Standard Time, UTC-06:00)  #    Comments [0]   Pocket PC | Symbol  |  Trackback
Copyright © 2008 RBA Consulting.