Blog Home 
Todd Myhre - Vista

RSS 2.0 Atom 1.0 CDF  
 
Sign In
 
 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
Copyright © 2009 RBA Consulting.