global env

set revn 140
set config 1
set unconfig 0

set i 0
foreach arg $argv {
   switch -glob -- $arg {
      -noconfig       { set config 0; set unconfig 0 }
      -unconfig       { set unconfig 1; set config 0 }
      -installdir     { set installDir       [lindex $argv [expr $i + 1]] }
      -rev            { set revn             [lindex $argv [expr $i + 1]] }
      -scripttosource { set scripttosource   [lindex $argv [expr $i + 1]] }
   }
   incr i
}

catch {source $scripttosource}

if { $config == 1 || $unconfig == 1 } {
   set config_dir "$installDir\\v$revn\\commonfiles\\configs"
   if { [ string compare -nocase "$env(ANSYS_SYSDIR)" "intel" ] == 0 } {
      set config_dir "$config_dir\\win32"
   } else {
      set config_dir "$config_dir\\$env(ANSYS_SYSDIR)"
   }
   set ANSYSLIC_DIR "$installDir\\shared_files\\licensing"

   set cmdPath ""
   if { $config == 1 } {
      set config_dir "$config_dir\\config"
      set cmdPath "$config_dir\\AnsConfigPolyflow.exe"
   } else {
      #$unconfig
      set config_dir "$config_dir\\unconfig"
      set cmdPath "$config_dir\\AnsUnconfigPolyflow.exe"
   }

   puts "\nRunning $cmdPath"
   exec $cmdPath -install
}

