Skip to content

scripts ws change bak 2017 12 15 diff

Atiq Rahman edited this page Mar 12, 2021 · 1 revision
diff --git a/PowerShell/Console.lnk b/PowerShell/Console.lnk
index 9cc8d7f..683d423 100644
Binary files a/PowerShell/Console.lnk and b/PowerShell/Console.lnk differ
diff --git a/PowerShell/Generate-Git-Diff.ps1 b/PowerShell/Generate-Git-Diff.ps1
index 9ce4f2b..f1c3175 100644
--- a/PowerShell/Generate-Git-Diff.ps1
+++ b/PowerShell/Generate-Git-Diff.ps1
@@ -1,35 +1,35 @@
-<# Date: 10/08/2017 13:57:17
- # Author: Atique
-
- Goals:
- * Generate diff file and open with a prefered editor
- 1. Minimal modification: does not apply git commands to change commit/staged
- 2. If file path provided only a
-
-
- Tech spec,
- 1. When no file path is specified on arg it assumes to run on the entire
- repository without limiting to a file
-
-
- Example Usage,
- $ . $env:PS_SC_DIR\Generate-Git-Diff.ps1 -s cached
- $ . $env:PS_SC_DIR\Generate-Git-Diff.ps1 general-solving/leetcode/024_swap-nodes-in-pairs.cs of
-
- Reference for Advanced Path Differentiation:
-  https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%
-    29.aspx?f=255&MSPPError=-2147217396
-  https://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
-  https://en.wikipedia.org/wiki/Filename
-  https://serverfault.com/questions/150740/linux-windows-unix-file-names-which-
-    characters-are-allowed-which-are-unesc
-
- #>
+<# Date: 10/08/2017 13:57:17
+ # Author: Atiq
+
+ Goals:
+ * Generate diff file and open with a prefered editor
+ 1. Minimal modification: does not apply git commands to change commit/staged
+ 2. If file path provided only a
+
+
+ Tech spec,
+ 1. When no file path is specified on arg it assumes to run on the entire
+ repository without limiting to a file
+
+
+ Example Usage,
+ $ . $env:PS_SC_DIR\Generate-Git-Diff.ps1 -s cached
+ $ . $env:PS_SC_DIR\Generate-Git-Diff.ps1 general-solving/leetcode/024_swap-nodes-in-pairs.cs of
+
+ Reference for Advanced Path Differentiation:
+  https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%
+  29.aspx?f=255&MSPPError=-2147217396
+  https://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
+  https://en.wikipedia.org/wiki/Filename
+  https://serverfault.com/questions/150740/linux-windows-unix-file-names-which-
+  characters-are-allowed-which-are-unesc
+
+ #>
 
 Param(
-    [Parameter(Mandatory=$false)] [alias("f")] [string]$FilePath,
-    [Parameter(Mandatory=$false)] [alias("s")] [string]$Status
-    )
+  [Parameter(Mandatory=$false)] [alias("f")] [string]$FilePath,
+  [Parameter(Mandatory=$false)] [alias("s")] [string]$Status
+  )
 
 
 # Check if it's Unix Style
@@ -40,84 +40,73 @@ Param(
 # Right now, for simplification, we substitute '/' with '\'
 
 function INIT() {
-    $global:IsTargetAFile = $true
-    if ($FilePath.Equals("")) {
-        $global:IsTargetAFile = $false
-    }
+  $global:IsTargetAFile = $true
+  if ($FilePath.Equals("")) {
+    $global:IsTargetAFile = $false
+  }
+  # Default Location
+  $Script:DefaultOutDir = 'D:\Docs\npp_files'
 }
 
-
 # Purpose of this function is to verify arguments
 function VERIFY_PARAMETERS() {
 
-    # Check if current location is a git repo
-    if (! (Test-Path .git -PathType Container)) {
-        return -1
-    }
-    if ($global:IsTargetAFile) {
-        # expected only file path, no directory
-        if (! (Test-Path $FilePath -PathType Leaf)) {
-            return -1
-        }
-    }
-    # check if outdir exists
-    if (! (Test-Path 'D:\npp_files' -PathType Container)) {
-        return -1
+  # Check if current location is a git repo
+  if (! (Test-Path .git -PathType Container)) {
+    return -1
+  }
+  if ($global:IsTargetAFile) {
+    # expected only file path, no directory
+    if (! (Test-Path $FilePath -PathType Leaf)) {
+      return -1
     }
+  }
+  # check if outdir exists
+  if (! (Test-Path $DefaultOutDir -PathType Container)) {
+    return -1
+  }
 
-    return 0
+  return 0
 }
 
 # Start of Main function
 function Main() {
-    INIT
-
-    if (VERIFY_PARAMETERS -le 0) {
-        Write-Host "Error Abort!"
-        break
-    }
-
-    if ($Status.Equals("openfile") -Or $Status.Equals("OpenFile") -Or $Status.Equals("of")) {
-        $Status = 'OpenFile'
+  INIT
+
+  if (VERIFY_PARAMETERS -le 0) {
+    Write-Host "Error Abort!"
+    break
+  }
+
+  if ($Status.Equals("openfile") -Or $Status.Equals("OpenFile") -Or $Status.Equals("of")) {
+    $Status = 'OpenFile'
+  }
+  elseif ($Status.StartsWith("cach") -or $Status.StartsWith("cahc") -or $Status.StartsWith("ccah")) {
+    $Status = '--cached'
+  }
+  else {
+    $Status = ''
+  }
+  $DiffFilePath = $DefaultOutDir + '\ProblemSolving-' + (Get-Date -UFormat "%Y-%m-%d") + '.diff'
+  if ($global:IsTargetAFile) {
+    if ($FilePath.Contains(':') -Or $FilePath.Contains('\')) {
+      Write-Host "Windows Style Path Detected in Input!"
     }
-    elseif ($Status.StartsWith("cach") -or $Status.StartsWith("cahc") -or $Status.StartsWith("ccah")) {
-        $Status = '--cached'
+    elseif ($FilePath.Contains('/')) {
+      $FilePath = $FilePath -replace '/','\'
     }
-    else {
-        $Status = ''
-    }
-    # Default Location
-    $DiffFilePath = 'D:\npp_files'
-    $DiffFilePath = $DiffFilePath + '\ProblemSolving-' + (Get-Date -UFormat "%Y-%m-%d") + '.diff'
-    if ($global:IsTargetAFile) {
-        if ($FilePath.Contains(':') -Or $FilePath.Contains('\')) {
-            Write-Host "Windows Style Path Detected in Input!"
-        }
-        elseif ($FilePath.Contains('/')) {
-            $FilePath = $FilePath -replace '/','\'
-        }
-    }
-    Write-Host "got f path $FilePath diff path $DiffFilePath and cach stat $Status"
-
-    # current hack for opening a file using  this script
-    if ($Status.Equals("OpenFile")) {
-        $Status = 'OpenFile'
-        # I think VS140COMNTOOLS is not related with visual studio 2017
-        # It's weird that I though of that and related that way..
-        # D:\PFiles_x86\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe"
-        # D:\PFiles_x86\Microsoft Visual Studio 14.0\Common7\Tools\..\..\2017\Professional\Common7\IDE\devenv.exe
-        $VSPATH = $env:VS140COMNTOOLS + '..\..\..\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe'
-        if (! (Test-Path $VSPATH -PathType Leaf)) {
-            Write-Host 'Visual Studio Dev Binary "' + $VSPATH + '" not found!'
-            break
-        }
-        & $VSPATH /Edit $FilePath
-        break
-    }
-
-    # Generate git diff
-    git --no-pager diff $Status $FilePath | Out-File $DiffFilePath
-    ss notepad++ $DiffFilePath
+  }
+  Write-Host "got f path $FilePath diff path $DiffFilePath and cach stat $Status"
+
+  # current hack for opening a file using  this script
+  if ($Status.Equals("OpenFile")) {
+    start devenv /Edit,$FilePath
+    break
+  }
+
+  # Generate git diff
+  git --no-pager diff $Status $FilePath | Out-File $DiffFilePath
+  Start-Process notepad++ $DiffFilePath
 }
 
 Main
diff --git a/PowerShell/Init.ps1 b/PowerShell/Init.ps1
index 75d868e..f16804c 100644
--- a/PowerShell/Init.ps1
+++ b/PowerShell/Init.ps1
@@ -1,510 +1,516 @@
 <#
-    Author : Atiq Rahman
-    Desc   : Initialization script for custom powershell
-    Purposes:
-        1. Initialize variables; set network status
-        2. Fix first time situations when profile does not exist, git is not installed
-        3. Set net
+  Author : Atiq Rahman
+  Desc   : Initialization script for custom powershell
+  Purposes:
+    1. Initialize variables; set network status
+    2. Fix first time situations when profile does not exist, git is not installed
+    3. Set net
 #>
 
 #######################################################################################################
-#####################       Functions' Definitions Start          #####################################
+#####################     Functions' Definitions Start      #####################################
 #######################################################################################################
 
 function InitializeScript([string] $m_netstatfile) {
-    # in case of an unclean shutdown
-    $global:netstatfile = $m_netstatfile
-    if (Test-Path $m_netstatfile) { Remove-Item $m_netstatfile }
-    $global:NET_STATUS = $false
-    # Go home; required to call any script from fftsys_ws\powershell directory
-    cd $env:PS_SC_DIR
+  # in case of an unclean shutdown
+  $global:netstatfile = $m_netstatfile
+  if (Test-Path $m_netstatfile) { Remove-Item $m_netstatfile }
+  $global:NET_STATUS = $false
+  # Go home; required to call any script from fftsys_ws\powershell directory
+  cd $env:PS_SC_DIR
 }
 
 # First time, we need to set this
 function FixProfile([string] $ScriptDrive) {
-    $env:PS_SC_DIR = $ScriptDrive+"\git_ws\fftsys_ws\Powershell"
-    if (! (Test-Path $profile)) {
-        # $ProfileDir = $env:HOMEDrive + $env:HOMEPATH + "\Documents\WindowsPowerShell"
-        $ProfileDir = $profile.Remove($profile.LastIndexOf("\"), $profile.Length-$profile.LastIndexOf("\"));
-        # Bug Fix, if my documents location changed this is required
-        if (! (Test-Path $ProfileDir)) { New-Item -ItemType directory -Path $ProfileDir }
-        $RepoProfileDir = $env:PS_SC_DIR+"\Microsoft.PowerShell_profile.ps1"
-        if (! (Test-Path $RepoProfileDir)) {
-            $RepoProfileDir
-            Write-Host "Please fix repository powershell profile path for import. Please check value of ScriptDrive."
-            break
-        }
-        Copy-Item $RepoProfileDir $profile
-        Write-Host "Profile $profile added. Please update host type in profile and run powershell again."
-        break
-    }
+  $env:PS_SC_DIR = $ScriptDrive+"\git_ws\fftsys_ws\Powershell"
+  if (! (Test-Path $profile)) {
+    # $ProfileDir = $env:HOMEDrive + $env:HOMEPATH + "\Documents\WindowsPowerShell"
+    $ProfileDir = $profile.Remove($profile.LastIndexOf("\"), $profile.Length-$profile.LastIndexOf("\"));
+    # Bug Fix, if my documents location changed this is required
+    if (! (Test-Path $ProfileDir)) { New-Item -ItemType directory -Path $ProfileDir }
+    $RepoProfileDir = $env:PS_SC_DIR+"\Microsoft.PowerShell_profile.ps1"
+    if (! (Test-Path $RepoProfileDir)) {
+      $RepoProfileDir
+      Write-Host "Please fix repository powershell profile path for import. Please check value of ScriptDrive."
+      break
+    }
+    Copy-Item $RepoProfileDir $profile
+    Write-Host "Profile $profile added. Please update host type in profile and run powershell again."
+    break
+  }
 }
 
 function FixGit() {
-    $EXEPATH = "X:\bin\Git"
-    if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
-        $EXEPATH = "D:\PFiles_x64\Git"
-    }
-    elseif ($HOST_TYPE.Equals("ORACLE_WS")) {
-        $EXEPATH = "D:\PFiles_x64\Git"
-    }
-
-    if (! (Test-Path "$EXEPATH")) {
-        Write-Host "Please install Git"
-        break
-    }
-    $GitPath = "$EXEPATH\cmd"
-    # Add path if already not added by system
-    $env:Path += $GitPath
-    $env:EXEPATH = $EXEPATH
-    $env:HOME = $env:PS_SC_DIR
-
-    # Generate gitconfig
-    git config --global user.email "[email protected]"
-    git config --global user.name "Atiq Rahman"
-    if ($HOST_TYPE.Equals("ORACLE_WS")) {
-        git config --global http.proxy http://www-proxy.us.oracle.com:80
-    }
+  $EXEPATH = "X:\bin\Git"
+  if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
+    $EXEPATH = $env:PFilesX64 + '\Git'
+  }
+  elseif ($HOST_TYPE.Equals("ORACLE_WS")) {
+    $EXEPATH = "D:\PFiles_x64\Git"
+  }
+
+  if (! (Test-Path "$EXEPATH")) {
+    Write-Host "Please install Git"
+    break
+  }
+  $GitPath = "$EXEPATH\cmd"
+  # Add path if already not added by system
+  $env:Path += $GitPath
+  $env:EXEPATH = $EXEPATH
+  $env:HOME = $env:PS_SC_DIR
+
+  # Generate gitconfig
+  git config --global user.email "[email protected]"
+  git config --global user.name "Atiq Rahman"
+  if ($HOST_TYPE.Equals("ORACLE_WS")) {
+    git config --global http.proxy http://www-proxy.us.oracle.com:80
+  }
 }
 
 # function only for sinc site
 function FixSINCEnvPath() {
-    $PSPath = $env:Path
-    # remove MOLECULAR EVOLUTIONARY GENETICS ANALYSIS 
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\MEGA6;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Caminova\Document Express DjVu Plug-in\;","")
-    $PSPath = $PSPath.replace("C:\Program Files\Citrix\Virtual Desktop Agent\;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Accelrys\Accelrys Draw 4.1\\lib;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Intuit\QBPOSSDKRuntime;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\QuickTime\QTSystem\;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\PharosSystems\Core;","")
-    $PSPath = $PSPath.replace("C:\Program Files\MATLAB\R2014a\bin;","")
-    $PSPath = $PSPath.replace("C:\Program Files\MATLAB\R2014a\bin\win64;","")
-    $PSPath = $PSPath.replace("C:\Program Files\SASHome\Secure\ccme4;","")
-    $PSPath = $PSPath.replace("C:\Program Files\SASHome\x86\Secure\ccme4;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Citrix\system32;","")
-    $PSPath = $PSPath.replace("C:\texlive\2014\bin\win32;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Asymptote;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Citrix\System32;","")
-    $PSPath = $PSPath.replace("C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;","")
-    $PSPath = $PSPath.replace("C:\texlive\2013\bin\win32;","")
-    $PSPath = $PSPath.replace("C:\app\rgonzalez\product\11.2.0\client_1;","")
-    $PSPath = $PSPath.replace("C:\app\oracle\product\11.2.0\client_1\bin;","")
-    
-    
-    # $PSPath = $PSPath.replace("","")
-
-    $env:Path = $PSPath
-    if (! $PSPath.StartsWith("C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;")) {
-        Write-Host "System path changed!"
-    }
+  $PSPath = $env:Path
+  # remove MOLECULAR EVOLUTIONARY GENETICS ANALYSIS 
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\MEGA6;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Caminova\Document Express DjVu Plug-in\;","")
+  $PSPath = $PSPath.replace("C:\Program Files\Citrix\Virtual Desktop Agent\;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Accelrys\Accelrys Draw 4.1\\lib;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Intuit\QBPOSSDKRuntime;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\QuickTime\QTSystem\;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\PharosSystems\Core;","")
+  $PSPath = $PSPath.replace("C:\Program Files\MATLAB\R2014a\bin;","")
+  $PSPath = $PSPath.replace("C:\Program Files\MATLAB\R2014a\bin\win64;","")
+  $PSPath = $PSPath.replace("C:\Program Files\SASHome\Secure\ccme4;","")
+  $PSPath = $PSPath.replace("C:\Program Files\SASHome\x86\Secure\ccme4;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Citrix\system32;","")
+  $PSPath = $PSPath.replace("C:\texlive\2014\bin\win32;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Asymptote;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\Common Files\Citrix\System32;","")
+  $PSPath = $PSPath.replace("C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;","")
+  $PSPath = $PSPath.replace("C:\texlive\2013\bin\win32;","")
+  $PSPath = $PSPath.replace("C:\app\rgonzalez\product\11.2.0\client_1;","")
+  $PSPath = $PSPath.replace("C:\app\oracle\product\11.2.0\client_1\bin;","")
+  
+  
+  # $PSPath = $PSPath.replace("","")
+
+  $env:Path = $PSPath
+  if (! $PSPath.StartsWith("C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;")) {
+    Write-Host "System path changed!"
+  }
 }
 
 # Update Internet Status; whether internet is reachable or not
 # Result is stored in variable $NETSTATUS
 function GetInternetNetStatus() {
-    $clnt = new-object System.Net.WebClient
-    $url = "http://saos.azurewebsites.net/Downloads/net.txt"
-    [bool] $res = $false
-
-    try {
-        $clnt.DownloadFile($url,$netstatfile)
-        if (SingleInstanceRunning) {
-            if ($HOST_TYPE.Equals("VSINC_SERVER_2008")) { Write-Host "`r`n" }
-            Write-Host -NoNewline "Connected to World Wide Inter-network"
-        }
+  $clnt = new-object System.Net.WebClient
+  $url = "http://saos.azurewebsites.net/Downloads/net.txt"
+  [bool] $res = $false
+
+  try {
+    $clnt.DownloadFile($url,$netstatfile)
+    if (SingleInstanceRunning) {
+      if ($HOST_TYPE.Equals("VSINC_SERVER_2008")) { Write-Host "`r`n" }
+      Write-Host -NoNewline "Connected to World Wide Inter-network"
     }
-    catch [Net.WebException] {
-        #Write-Host $_.Exception.ToString()
-        if (SingleInstanceRunning) {
-            Write-Host -foregroundcolor red "Could not reach world wide internetwork!`n"
-        }
+  }
+  catch [Net.WebException] {
+    #Write-Host $_.Exception.ToString()
+    if (SingleInstanceRunning) {
+      Write-Host -foregroundcolor red "Could not reach world wide internetwork!`n"
+    }
+  }
+
+  if (Test-Path $netstatfile) {
+    $tmpText = $(cat $netstatfile)
+    if ($tmpText.Equals("on")) {
+      if (SingleInstanceRunning) {
+        Write-Host -NoNewline " [powered by "
+        Write-Host -NoNewline -foregroundcolor green "fftsys.com"
+        Write-Host "]"
+      }
+      $res = $true
+    }
+    elseif ($tmpText | Select-String "Recharge Your Banglalion Acccount") {
+      Write-Host -NoNewline " ["
+      Write-Host -NoNewline -foregroundcolor red "Banglalion not active yet"
+      Write-Host "]"
+      Remove-Item $netstatfile
     }
-
-    if (Test-Path $netstatfile) {
-        $tmpText = $(cat $netstatfile)
-        if ($tmpText.Equals("on")) {
-            if (SingleInstanceRunning) {
-                Write-Host -NoNewline " [powered by "
-                Write-Host -NoNewline -foregroundcolor green "fftsys.com"
-                Write-Host "]"
-            }
-            $res = $true
-        }
-        elseif ($tmpText | Select-String "Recharge Your Banglalion Acccount") {
-            Write-Host -NoNewline " ["
-            Write-Host -NoNewline -foregroundcolor red "Banglalion not active yet"
-            Write-Host "]"
-            Remove-Item $netstatfile
-        }
-        else {
-            Write-Host " [debug] retrieved file is damanged. Please check connection."
-        }
-        Remove-Item $netstatfile
+    else {
+      Write-Host " [debug] retrieved file is damanged. Please check connection."
     }
-    return $res
+    Remove-Item $netstatfile
+  }
+  return $res
 }
 
 function ResizeConsole([string] $title, [int] $history_size, [int] $width, [int] $height) {
-    # Get console UI
-    $cUI = (Get-Host).UI.RawUI
-
-    $cUI.WindowTitle = $title
-
-    # change buffer size, otherwise error
-    $b = $cUI.BufferSize
-    $b.Width = $width
-    $b.Height = $history_size
-    $cUI.BufferSize = $b
-
-    # change window height and width
-    $b = $cUI.WindowSize
-    $b.Width = $width
-    $b.Height = $height
-    $cUI.WindowSize = $b
+  # Get console UI
+  $cUI = (Get-Host).UI.RawUI
+
+  $cUI.WindowTitle = $title
+
+  # change buffer size, otherwise error
+  $b = $cUI.BufferSize
+  $b.Width = $width
+  $b.Height = $history_size
+  $cUI.BufferSize = $b
+
+  # change window height and width
+  $b = $cUI.WindowSize
+  $b.Width = $width
+  $b.Height = $height
+  $cUI.WindowSize = $b
 }
 
 <# Fix this function if used, it is obsolete
 function return type should be host type if can be relevant
 
 function NotDetectedOfficeNetwork() {
-    $res = $true
-    # In case we don't use wifi we should use ping reply from gateway like 192.168.20.1
-    # In some cases gateway might not reply; then we can check for a secondary gateway
-
-    $wifi_bssid_list=netsh wlan sh net mode=bssid
-    # assuming wifi is enabled
-    # wifi check is required as long as separate PC has not been bought
-    if ($wifi_bssid_list | Select-String "no wireless interface") {
-        # Detect using LAN
-        # Gateway IP for lan
-        $GatewayIP = "192.168.20.1"
-        # ref: http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/24/use-powershell-to-test-connectivity-on-remote-servers.aspx
-        if (Test-Connection -Cn $GatewayIP -BufferSize 16 -Count 1 -ea 0 -quiet) {
-            $res = $false
-        }
-    }
-    elseif (($wifi_bssid_list | Select-String REVE) -Or ($wifi_bssid_list | Select-String VPN_TP-LINK_8th_Floor)) {
-       $res = $false
-    }
-    return $res
+  $res = $true
+  # In case we don't use wifi we should use ping reply from gateway like 192.168.20.1
+  # In some cases gateway might not reply; then we can check for a secondary gateway
+
+  $wifi_bssid_list=netsh wlan sh net mode=bssid
+  # assuming wifi is enabled
+  # wifi check is required as long as separate PC has not been bought
+  if ($wifi_bssid_list | Select-String "no wireless interface") {
+    # Detect using LAN
+    # Gateway IP for lan
+    $GatewayIP = "192.168.20.1"
+    # ref: http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/24/use-powershell-to-test-connectivity-on-remote-servers.aspx
+    if (Test-Connection -Cn $GatewayIP -BufferSize 16 -Count 1 -ea 0 -quiet) {
+      $res = $false
+    }
+  }
+  elseif (($wifi_bssid_list | Select-String REVE) -Or ($wifi_bssid_list | Select-String VPN_TP-LINK_8th_Floor)) {
+     $res = $false
+  }
+  return $res
 }#>
 
 # Settings for Residence
 function ApplyHomeSettings() {
-    # As we are getting "Unable to modify shortcut error", doing this from here; run only in office, I can't change the console properties in Win8 there
-    # Get display proportionat size
-    # CurrentHorizontalResolution, CurrentVerticalResolution
-    $screen_width = [convert]::ToInt32([string] ((GWMI win32_videocontroller).CurrentHorizontalResolution))
-    $screen_height = [convert]::ToInt32([string] ((GWMI win32_videocontroller).CurrentVerticalResolution))
+  # As we are getting "Unable to modify shortcut error", doing this from here; run only in office, I can't change the console properties in Win8 there
+  # Get display proportionat size
+  # CurrentHorizontalResolution, CurrentVerticalResolution
+  $screen_width = [convert]::ToInt32([string] ((GWMI win32_videocontroller).CurrentHorizontalResolution))
+  $screen_height = [convert]::ToInt32([string] ((GWMI win32_videocontroller).CurrentVerticalResolution))
+  
+  <#
+    Default aspect Ratio: 16:9
+    128 43 is not okay for 5:4
+    it should be 155 40
     
-    
-    <#
-        Default aspect Ratio: 16:9
-        128 43 is not okay for 5:4
-        it should be 155 40
-        
-        10 24 is okay for aspect ratio 16:9
-        9 22 for 1366x768
-    #>
-    $console_width = $screen_width/16
-    $console_height = $screen_height/48
-
-    # Aspect Ratio: 5:4 - HSL library monitor
-    # result should be close to 155 40
-    if (($screen_width*4) -eq ($screen_height*5)) {
-        $console_width = [int] ($screen_width/10)
-        $console_height = [int] ($screen_height/21)
-    }
-
-
-    # ResizeConsole "SA Matrix Workstation" 6144 130 33
-    ResizeConsole "SA Matrix Workstation" 9999 $console_width $console_height
-    # Write-Host "Welcome $env:username to SA Matrix Workstation`r`n" -foregroundcolor Blue
-    Write-Host "Applying settings on Matrix Workstation for $env:username"
+    10 24 is okay for aspect ratio 16:9
+    9 22 for 1366x768
+  #>
+  $console_width = $screen_width/16
+  $console_height = $screen_height/48
+
+  # Aspect Ratio: 5:4 - HSL library monitor
+  # result should be close to 155 40
+  if (($screen_width*4) -eq ($screen_height*5)) {
+    $console_width = [int] ($screen_width/10)
+    $console_height = [int] ($screen_height/21)
+  }
+
+
+  # ResizeConsole "SA Matrix Workstation" 6144 130 33
+  ResizeConsole "SA Matrix Workstation" 9999 $console_width $console_height
+  # Write-Host "Welcome $env:username to SA Matrix Workstation`r`n" -foregroundcolor Blue
+  Write-Host "Applying settings on Matrix Workstation for $env:username"
+  Write-Host " "
+
+
+  <# Banglalion info is no more required. Besides it is not working still I have come to US
+  
+  if(SingleInstanceRunning -and $NET_STATUS) {
+    .\Show-Blpackageinfo.ps1
     Write-Host " "
-
-
-    <# Banglalion info is no more required. Besides it is not working still I have come to US
-    
-    if(SingleInstanceRunning -and $NET_STATUS) {
-        .\Show-Blpackageinfo.ps1
-        Write-Host " "
-    } #>
+  } #>
 }
 
 # Settings for Oracle
 function ApplyJUSettings() {
-    # As we are getting "Unable to modify shortcut error", doing this from here; run only in office, I can't change the console properties in Win8 there
-    ResizeConsole "Oracle Workstation Matrix" 9999 190 45
-    # Write-Host "Welcome $env:username to SA Matrix Workstation`r`n" -foregroundcolor Blue
-    Write-Host "Applying office settings on Oracle Workstation for $env:username"
+  # As we are getting "Unable to modify shortcut error", doing this from here; run only in office, I can't change the console properties in Win8 there
+  ResizeConsole "Oracle Workstation Matrix" 9999 190 45
+  # Write-Host "Welcome $env:username to SA Matrix Workstation`r`n" -foregroundcolor Blue
+  Write-Host "Applying office settings on Oracle Workstation for $env:username"
+  Write-Host " "
+
+  <# Banglalion info is no more required. Besides it is not working still I have come to US
+  
+  if(SingleInstanceRunning -and $NET_STATUS) {
+    .\Show-Blpackageinfo.ps1
     Write-Host " "
-
-    <# Banglalion info is no more required. Besides it is not working still I have come to US
-    
-    if(SingleInstanceRunning -and $NET_STATUS) {
-        .\Show-Blpackageinfo.ps1
-        Write-Host " "
-    } #>
+  } #>
 }
 
 # Settings for virtual SINC site
 function ApplyVSINCSettings() {
-    # Only to change title
-    # (Get-Host).UI.RawUI.WindowTitle = "SA VSINC Matrix Workstation"
-    ResizeConsole "SA VSINC Matrix Workstation" 9999 185 45
+  # Only to change title
+  # (Get-Host).UI.RawUI.WindowTitle = "SA VSINC Matrix Workstation"
+  ResizeConsole "SA VSINC Matrix Workstation" 9999 185 45
 
-    # Setting for V Sinc
-    Write-Host "Applying Virtual SINC Site settings for $env:username"
+  # Setting for V Sinc
+  Write-Host "Applying Virtual SINC Site settings for $env:username"
 }
 
 # Check whether it is a new day after last login
 function LoginNotDone() {
-    # [bool] $updateDone = $true
-    # required for hajirakhata login
-    # hajirakhata login checks if it is set to false to satisfy final condition
-
-    $CurDate = [int] $(Get-Date).Day
-
-    if (! (Test-Path date.txt)) { "32" | Out-File .\date.txt }
-    $PreDate = [int] $(cat date.txt)
-
-    if ($CurDate -ne $PreDate) {
-        # Update Login Status
-        # Login manually if hk-login fails
-        $CurDate | Out-File .\date.txt
-        return $true
-    }
-    return $false
+  # [bool] $updateDone = $true
+  # required for hajirakhata login
+  # hajirakhata login checks if it is set to false to satisfy final condition
+
+  $CurDate = [int] $(Get-Date).Day
+
+  if (! (Test-Path date.txt)) { "32" | Out-File .\date.txt }
+  $PreDate = [int] $(cat date.txt)
+
+  if ($CurDate -ne $PreDate) {
+    # Update Login Status
+    # Login manually if hk-login fails
+    $CurDate | Out-File .\date.txt
+    return $true
+  }
+  return $false
 }
 
 <#
 Obsolete for now
 function ApplyOfficeSettings() {
-    ResizeConsole "SA SINC Workstation" 160 40
+  ResizeConsole "SA SINC Workstation" 160 40
 
-    # Setting for office
-    if (SingleInstanceRunning) {
-        Write-Host "Applying office settings on REVE Workstation for $env:username"
-    }
+  # Setting for office
+  if (SingleInstanceRunning) {
+    Write-Host "Applying office settings on REVE Workstation for $env:username"
+  }
 
-    # Attempt log-in if internet is set true    
-    if($NET_STATUS) {
-        if (LoginNotDone) {
-            .\hk-LogIn.ps1
-        }
-        elseif (SingleInstanceRunning) {
-            Write-Host "Already logged into hajirakhata.`n"
-        }
+  # Attempt log-in if internet is set true  
+  if($NET_STATUS) {
+    if (LoginNotDone) {
+      .\hk-LogIn.ps1
     }
-    else {
-        Write-Host "Login skipped"
+    elseif (SingleInstanceRunning) {
+      Write-Host "Already logged into hajirakhata.`n"
     }
+  }
+  else {
+    Write-Host "Login skipped"
+  }
 }
 #>
 
 # Currently only updates fftsys_ws repository using git
 function UpdateCoreRepo() {
-    # Add git path if necessary
-    # $env:path += ";"+$GitPath
-
-    # update scripts if internet is available and day is a new day
-    if ($NET_STATUS) {
-        git pull origin master
-        # .\svn.ps1 up 1
-        Write-Host " "
-        <#.\svn.ps1 up 1 | tee-object -filepath svnlog.txt
-        #.\svn.ps1 up 1 > svnlog.txt
-        
-        if (cat svnlog.txt | select-string "revision") {
-            Write-Host " "
-        # if svn up is successful update state and date file
-            if ($UPDATEDONE.Equals("FALSE")) {
-                echo "$CurDate" > date.txt
-                $UPDATEDONE = "TRUE"
-            }
-        }#>
-    }
-    else {
-        Write-Host "Scripts not updated. Internet is not available."
-    }
+  # Add git path if necessary
+  # $env:path += ";"+$GitPath
+
+  # update scripts if internet is available and day is a new day
+  if ($NET_STATUS) {
+    git pull origin master
+    # .\svn.ps1 up 1
+    Write-Host " "
+    <#.\svn.ps1 up 1 | tee-object -filepath svnlog.txt
+    #.\svn.ps1 up 1 > svnlog.txt
+    
+    if (cat svnlog.txt | select-string "revision") {
+      Write-Host " "
+    # if svn up is successful update state and date file
+      if ($UPDATEDONE.Equals("FALSE")) {
+        echo "$CurDate" > date.txt
+        $UPDATEDONE = "TRUE"
+      }
+    }#>
+  }
+  else {
+    Write-Host "Scripts not updated. Internet is not available."
+  }
 }
 
 function ShowGadgets() {
-    # Display weather update
-    if ($NET_STATUS) {
-        .\Weather-Update
-    }
-    else {
-        Write-Host "Weather info retrieval skipped`n"
-    }
+  # Display weather update
+  if ($NET_STATUS) {
+    .\Weather-Update
+  }
+  else {
+    Write-Host "Weather info retrieval skipped`n"
+  }
 }
 
 function StartCustomPrcoesses() {
-    if($NET_STATUS) {
-        # Shame this 64 bit chrome is installed in 32 bit program files
-        if ($HOST_TYPE.Equals("PC_NOTEBOOK") -or $HOST_TYPE.Equals("ORACLE_WS") -or $HOST_TYPE.Equals("CS_GRAD_LAB_1227")) {
-            Start-Process-Single "chrome" "Google Chrome" "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"
-        }
-        elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
-            Start-Process-Single "iexplore" "Internet Explorer" "C:\Program Files\Internet Explorer\iexplore.exe"
-            # Start-Process iexplore
-        }
-        # Start-Process-Single "chrome" "Google Chrome" "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe"
+  if($NET_STATUS) {
+    # Shame this 64 bit chrome is installed in 32 bit program files
+    if ($HOST_TYPE.Equals("PC_NOTEBOOK") -or $HOST_TYPE.Equals("ORACLE_WS") -or $HOST_TYPE.Equals("CS_GRAD_LAB_1227")) {
+      Start-Process-Single "chrome" "Google Chrome" "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"
+    }
+    elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
+      Start-Process-Single "iexplore" "Internet Explorer" "C:\Program Files\Internet Explorer\iexplore.exe"
+      # Start-Process iexplore
+    }
+    # Start-Process-Single "chrome" "Google Chrome" "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe"
+  }
+  else {
+    Write-Host "Starting processes skipped"
+    return
+  }
+  <# Fix Program Files for x86, residential PC is x86
+  if (${env:PROCESSOR_ARCHITECTURE}.Equals("x86")) {
+    ${env:ProgramFiles(x86)} = $env:ProgramFiles
+    Write-Host "Var set to" ${env:ProgramFiles(x86)}
+  }#>
+
+  # Let's start notepad++
+  if (Get-Process notepad++ -ErrorAction SilentlyContinue) {
+    Write-Host "Notepad++ is already running"
+  }
+  else {
+    if ($HOST_TYPE.Equals("PC_NOTEBOOK") -or $HOST_TYPE.Equals("ORACLE_WS") -or $HOST_TYPE.Equals("CS_GRAD_LAB_1227")) {
+      # ss instead of start because in sinc site notepad++ is local
+      # but this causes the script to stop execution after this point
+      # ss notepad++
+      Write-Host "Starting notepad++"
+      start notepad++
     }
     else {
-        Write-Host "Starting processes skipped"
-        return
+      Write-Host "Notepad++ is not configured for this host!"      
     }
-    <# Fix Program Files for x86, residential PC is x86
-    if (${env:PROCESSOR_ARCHITECTURE}.Equals("x86")) {
-        ${env:ProgramFiles(x86)} = $env:ProgramFiles
-        Write-Host "Var set to" ${env:ProgramFiles(x86)}
-    }#>
+  }
 
-    # Let's start notepad++
-    if (Get-Process notepad++ -ErrorAction SilentlyContinue) {
-        Write-Host "Notepad++ is already running"
-    }
-    else {
-        if ($HOST_TYPE.Equals("PC_NOTEBOOK") -or $HOST_TYPE.Equals("ORACLE_WS") -or $HOST_TYPE.Equals("CS_GRAD_LAB_1227")) {
-            # ss instead of start because in sinc site notepad++ is local
-            # but this causes the script to stop execution after this point
-            # ss notepad++
-            Write-Host "Starting notepad++"
-            start notepad++
-        }
-        else {
-            Write-Host "Notepad++ is not configured for this host!"            
-        }
-    }
-
-    <# Let's get skype as well
-    if ($HOST_TYPE.Equals("ORACLE_WS")) {
-        # ss instead of start because in sinc site notepad++ is local
-        # but this causes the script to stop execution after this point
-        # ss notepad++
-        # Write-Host "Starting skype"
-        Start-Process-Single "skype" "Skype" "${env:ProgramFiles(x86)}\Skype\Phone\Skype.exe"
-    }#>
+  <# Let's get skype as well
+  if ($HOST_TYPE.Equals("ORACLE_WS")) {
+    # ss instead of start because in sinc site notepad++ is local
+    # but this causes the script to stop execution after this point
+    # ss notepad++
+    # Write-Host "Starting skype"
+    Start-Process-Single "skype" "Skype" "${env:ProgramFiles(x86)}\Skype\Phone\Skype.exe"
+  }#>
 
 }
 
 function Start-Process-Single([string] $ProcessRunCommand, [string] $ProcessName, [string] $ProcessPath) {
-    if (Get-Process $ProcessRunCommand -ErrorAction SilentlyContinue) {
-        Write-Host "$ProcessName is already running"
+  if (Get-Process $ProcessRunCommand -ErrorAction SilentlyContinue) {
+    Write-Host "$ProcessName is already running"
+  }
+  else {
+    if ((Test-Path "$ProcessPath")) {
+      Write-Host "Starting $ProcessName"
+      start $ProcessPath
     }
     else {
-        if ((Test-Path "$ProcessPath")) {
-            Write-Host "Starting $ProcessName"
-            start $ProcessPath
-        }
-        else {
-            Write-Host "$ProcessName is not installed."
-        }
+      Write-Host "$ProcessName is not installed."
     }
+  }
 }
 
+<#
+    In future selectively choose what paths should be in global var
+#>
 function UpdateVisualStudioDevToolsPath() {
-    # C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSTSDB\Deploy;C:\ProgramFiles (x86)\Microsoft Visual Studio 11.0\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN;C:\Program Files (x86)\Microsoft Visual Studio11.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\VCPackages;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.0\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\;
-
-    # Update path environment variable for Visual Studio Tools
-    if (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN") {
-        Write-Host "Initialized Visual Studio 11.0 Tools"
-        # VS 2012
-        $env:path += ";C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy;C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN;C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files\Microsoft Visual Studio 10.0\VC\VCPackages;C:\Program Files\HTMLHelp Workshop;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools;C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools;C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin"
-
-        # VS 2010
-        # $env:path += ";C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSTSDB\Deploy;C:\ProgramFiles (x86)\Microsoft Visual Studio 11.0\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN;C:\Program Files (x86)\Microsoft Visual Studio11.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\VCPackages;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.0\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\"
-    }
+  # C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSTSDB\Deploy;C:\ProgramFiles (x86)\Microsoft Visual Studio 11.0\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN;C:\Program Files (x86)\Microsoft Visual Studio11.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\VCPackages;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.0\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\;
+  # in future
+  # Update path environment variable for Visual Studio Tools
+  if (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN") {
+    Write-Host "Initialized Visual Studio 11.0 Tools"
+    # VS 2012
+    $env:path += ";C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy;C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN;C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files\Microsoft Visual Studio 10.0\VC\VCPackages;C:\Program Files\HTMLHelp Workshop;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools;C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools;C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin"
+
+    # VS 2010
+    # $env:path += ";C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSTSDB\Deploy;C:\ProgramFiles (x86)\Microsoft Visual Studio 11.0\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN;C:\Program Files (x86)\Microsoft Visual Studio11.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\VCPackages;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.0\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\"
+  }
 }
 
 [bool] $isSinglePS=$false
 function SingleInstanceRunning()
 {
-    $isSinglePS = $Global:isSinglePS
-    if ($isSinglePS) {
-        return $isSinglePS
-    }
-    if (GetProcessInstanceNumber "powershell" -lt 2) {
-        $isSinglePS = $true
-    }
-    $Global:isSinglePS = $isSinglePS
+  $isSinglePS = $Global:isSinglePS
+  if ($isSinglePS) {
     return $isSinglePS
+  }
+  if (GetProcessInstanceNumber "powershell" -lt 2) {
+    $isSinglePS = $true
+  }
+  $Global:isSinglePS = $isSinglePS
+  return $isSinglePS
 }
 
 # Get number of instances of a process
 function GetProcessInstanceNumber([string]$process)
 {
-    @(Get-Process $process -ErrorAction 0).Count
+  @(Get-Process $process -ErrorAction 0).Count
 }
 
 
-#####################      Function Definition Ends             #####################################
+#####################    Function Definition Ends       #####################################
 #######################################################################################################
 
 function Main() {
-    if (SingleInstanceRunning) {
-        # When powershell profile is not fixed, this has to be set manually for first time
-        # FixProfile "C:"
-        # FixProfile "D:"
-        FixGit
-        if ($HOST_TYPE.Equals("VSINC_SERVER_2008")) { FixSINCEnvPath }
-    }
-    else {
-        $n = GetProcessInstanceNumber "powershell"
-        Write-Host -NoNewline "Initializing powershell instance $n.."
-    }
-
-    # Initialization function; cannot run until profile and svn has been fixed
-    # Initialization operations like deleting files before starting
-    InitializeScript "${env:PS_SC_DIR}\tmp.txt"
-    $NET_STATUS = GetInternetNetStatus
-
-    <#
-    No need to detect REVE's network anymore
-    # temporarily override $matrix variable with office net availability checking
-    # later we will turn this off when we buy separate PC
-    if ($NET_STATUS) {
-        # this is broken: variable $IS_MATRIX is obsolete
-        $HOST_TYPE = NotDetectedOfficeNetwork
-        # Write-Host "[debug] value of host type" $HOST_TYPE
-    }
-    #>
-
-    # Apply settings
-    if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
-        ApplyHomeSettings
-    }
-    elseif ($HOST_TYPE.Equals("ORACLE_WS")) {
-        ApplyJUSettings
-    }
-    else {
-        # ApplyOfficeSettings
-        ApplyVSINCSettings
-    }
-
-    if (SingleInstanceRunning) {
-        # Update Repository
-        UpdateCoreRepo
-
-        # Current gadgets are weather gadget
-        # ShowGadgets
-
-        # Start other most frequently opened processes
-        StartCustomPrcoesses
-    }
-    else {
-        Write-Host  "`t`t`[Ready`]"
-    }
-    # Currently updates to add visual studio 2012 tools with Windows SDK
-    # UpdateVisualStudioDevToolsPath
-
-    # Show brief help
-    ss help
-    }
+  # Set up variables for Program Files
+  $env:PFilesX64 = 'D:\PFiles_x64'
+  $env:PFilesX86 = 'D:\PFiles_x86'
+
+  if (SingleInstanceRunning) {
+    # When powershell profile is not fixed, this has to be set manually for first time
+    # FixProfile "C:"
+    # FixProfile "D:"
+    FixGit
+    if ($HOST_TYPE.Equals("VSINC_SERVER_2008")) { FixSINCEnvPath }
+  }
+  else {
+    $n = GetProcessInstanceNumber "powershell"
+    Write-Host -NoNewline "Initializing powershell instance $n.."
+  }
+
+  # Initialization function; cannot run until profile and svn has been fixed
+  # Initialization operations like deleting files before starting
+  InitializeScript "${env:PS_SC_DIR}\tmp.txt"
+  $NET_STATUS = GetInternetNetStatus
+
+  <#
+  No need to detect REVE's network anymore
+  # temporarily override $matrix variable with office net availability checking
+  # later we will turn this off when we buy separate PC
+  if ($NET_STATUS) {
+    # this is broken: variable $IS_MATRIX is obsolete
+    $HOST_TYPE = NotDetectedOfficeNetwork
+    # Write-Host "[debug] value of host type" $HOST_TYPE
+  }
+  #>
+
+  # Apply settings
+  if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
+    ApplyHomeSettings
+  }
+  elseif ($HOST_TYPE.Equals("ORACLE_WS")) {
+    ApplyJUSettings
+  }
+  else {
+    # ApplyOfficeSettings
+    ApplyVSINCSettings
+  }
+
+  if (SingleInstanceRunning) {
+    # Update Repository
+    UpdateCoreRepo
+
+    # Current gadgets are weather gadget
+    # ShowGadgets
+
+    # Start other most frequently opened processes
+    StartCustomPrcoesses
+  }
+  else {
+    Write-Host  "`t`t`[Ready`]"
+  }
+  # Currently updates to add visual studio 2012 tools with Windows SDK
+  # UpdateVisualStudioDevToolsPath
+
+  # Show brief help
+  ss help
+  }
 
 Main
diff --git a/PowerShell/Stream-Converter.ps1 b/PowerShell/Stream-Converter.ps1
index 83b6ba8..5f06dc4 100644
--- a/PowerShell/Stream-Converter.ps1
+++ b/PowerShell/Stream-Converter.ps1
@@ -95,8 +95,8 @@ Param(
 
 #######################################################################################################
 ##################     Global variables declarations start      #################################
-$FFMPEG2EXE="D:\Soft\ffmpeg-20171109-723b6ba-win64-shared\bin\ffmpeg.exe"
-$MEDIAINFOEXE="D:\Soft\MediaInfo_GUI_0.7.92.1_Windows_x64_WithoutInstaller\MediaInfo.exe"
+$FFMPEG2EXE="D:\PFiles_x64\PT\ffmpeg-20171213-2e391a5-win64-shared\bin\ffmpeg.exe"
+$MEDIAINFOEXE="D:\PFiles_x64\PT\MediaInfo_GUI\MediaInfo.exe"
 [int] $global:CompressLevel = 0
 
 
@@ -209,7 +209,7 @@ function PerformSimpleCommand() {
       Write-Host "Please correct path for media info and then run the script again.`n"
       break
     }
-    & $MEDIAINFOEXE $StreamPath
+    Start-Process MediaInfo $StreamPath
     break
   }
   # Show Information with ffmpeg, observe for difference with mediainfo
@@ -549,6 +549,8 @@ function PerformOperationOnSingleFile ([int] $m_CompressLevel, [string] $SFilePa
       # & $FFMPEG2EXE -i "$SFilePath" -map -vcodec copy -map -acodec copy $DestFilePath
       if ($isAudioSupported) {
         & $FFMPEG2EXE -i "$SFilePath" -sn -dn -c:v copy -c:a copy $DestFilePath
+        # use this forcefully select a different audio stream index
+        # & $FFMPEG2EXE -i "$SFilePath" -sn -dn -c:v copy -map 0`:0 -c:a copy -map 0`:2 $DestFilePath
       }
       else {
         <# convert unsupported audio
diff --git a/PowerShell/logout.ps1 b/PowerShell/logout.ps1
index 0941276..6bd3dae 100644
--- a/PowerShell/logout.ps1
+++ b/PowerShell/logout.ps1
@@ -3,50 +3,50 @@
  # 	1. Create Bakup folder[$env:PS_SC_DIR\Bakup] if doesn't exist
  #  2. Once init.ps1 is performed we are sure that file $profile exists
 
-       Find current powershell profile path and copies current changed profile there
+     Find current powershell profile path and copies current changed profile there
 		which means change in current profile (ss ep) come into effect when next time powershell is run.
  #>
 
 # CMD arg validation
 if ($args.Count -eq 0) {
-    $cmd = [string] ""
+  $cmd = [string] ""
 }
 elseif ($args.Count -eq 1) {
-    $cmd = [string]$args
-    if (-not $cmd.Equals("skipsvn")) {
-        Write-Host -ForegroundColor Red "Logout: wrong cmd arg!`r`nCurrently only supported argument is skipsvn.`r`n"
-        break
-    }
+  $cmd = [string]$args
+  if (-not $cmd.Equals("skipsvn")) {
+    Write-Host -ForegroundColor Red "Logout: wrong cmd arg!`r`nCurrently only supported argument is skipsvn.`r`n"
+    break
+  }
 }
 else {
-    Write-Host "Wrong cmd args!"
-    break
+  Write-Host "Wrong cmd args!"
+  break
 }
 
 # function definition starts
 function UpdatePSProfile() {
-    # only perform if file has changed different
-    if (Compare-Object -ReferenceObject (Get-Content $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1) -DifferenceObject (Get-Content $profile)) {
-        ######## Get local copy of profile #####################
-        Write-Host "Bringing local copy of profile into documents dir"
+  # only perform if file has changed different
+  if (Compare-Object -ReferenceObject (Get-Content $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1) -DifferenceObject (Get-Content $PROFILE)) {
+    ######## Get local copy of profile #####################
+    Write-Host "Bringing local copy of profile into documents dir"
 
-        # Create Bakup folder if doesn't exist
-        if ( -not (Test-Path $env:PS_SC_DIR\Bakup)) { New-Item -ItemType Directory $env:PS_SC_DIR\Bakup }
+    # Create Bakup folder if doesn't exist
+    if ( -not (Test-Path $env:PS_SC_DIR\Bakup)) { New-Item -ItemType Directory $env:PS_SC_DIR\Bakup }
 
 
-        # If there is a folder called WindowsPowerShell inside Bakup force delete it and copy
-        # We are using copy instead of move so that next get-item command works
-        Copy-Item -Force $profile $env:PS_SC_DIR\Bakup
+    # If there is a folder called WindowsPowerShell inside Bakup force delete it and copy
+    # We are using copy instead of move so that next get-item command works
+    Copy-Item -Force $profile $env:PS_SC_DIR\Bakup
 
-        #$ProfileDir = $profile.Remove($profile.LastIndexOf("\"), $profile.Length-$profile.LastIndexOf("\"));
-        # Easier way: not the parent of the parent
-        #$ProfileDir = (Get-Item $profile).Directory.Parent.FullName
-        $ProfileDir = (Get-Item $profile).Directory.FullName
+    #$ProfileDir = $profile.Remove($profile.LastIndexOf("\"), $profile.Length-$profile.LastIndexOf("\"));
+    # Easier way: not the parent of the parent
+    #$ProfileDir = (Get-Item $profile).Directory.Parent.FullName
+    $ProfileDir = (Get-Item $profile).Directory.FullName
 
-        if ( -not (Test-Path $ProfileDir)) { New-Item -ItemType Directory $ProfileDir }
-        # Force because previous file still exists there
-        Copy-Item -Force $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1 $ProfileDir
-    }
+    if ( -not (Test-Path $ProfileDir)) { New-Item -ItemType Directory $ProfileDir }
+    # Force because previous file still exists there
+    Copy-Item -Force $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1 $ProfileDir
+  }
 }
 
 
@@ -55,54 +55,54 @@ No more required
 $ungcpath="$env:PS_SC_DIR\ungc.lnk"
 
 if (Test-Path $ungcpath) {
-    Write-Host "Processing Google Chrome uninstall request"
-    & $ungcpath
+  Write-Host "Processing Google Chrome uninstall request"
+  & $ungcpath
 }#>
 
 function PerformSVNCommit() {
-    # Commit scripts
-    Write-Host "Committing scripts back"
-    $logFilePath = "$env:PS_SC_DIR\..\Conf\svnerr.log"
-
-    if (Test-path $logFilePath) { rm $logFilePath }
-
-    #(& $env:PS_SC_DIR\svn.ps1 ci 1) 2> >(tee svnlog.txt >&2)
-    #(& $env:PS_SC_DIR\svn.ps1 ci 1)>(tee Conf\svnout.log) 2> >(tee Conf\\svnerr.log >&2)
-    (& $env:PS_SC_DIR\svn.ps1 ci 1) 2> $logFilePath
-
-    if (!(Test-path $logFilePath) -or (cat $logFilePath | select-string "fail")) {
-        #cat $env:PS_SC_DIR\Conf\svnerr.log
-        Write-Host "Scripts not comitted!"
-        Write-Host "`nError log`n======================================================"
-        cat $logFilePath
-    }
-    else {
-        Write-Host "Upload success"
-        Write-Host "Shutting down shell.."
-        Start-Sleep -s 3
-
-        #Reference for $host exit: http://mshforfun.blogspot.com/2006/08/do-you-know-there-is-host-variable.html
-        $host.SetShouldExit(0)
-
-        <# Experiment
-        Write-Host "Press any key.. "
-        $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")         # reference: http://technet.microsoft.com/en-us/library/ff730938.aspx
-        Write-Host "You entered $x"
-        #>
-
-    }
+  # Commit scripts
+  Write-Host "Committing scripts back"
+  $logFilePath = "$env:PS_SC_DIR\..\Conf\svnerr.log"
+
+  if (Test-path $logFilePath) { rm $logFilePath }
+
+  #(& $env:PS_SC_DIR\svn.ps1 ci 1) 2> >(tee svnlog.txt >&2)
+  #(& $env:PS_SC_DIR\svn.ps1 ci 1)>(tee Conf\svnout.log) 2> >(tee Conf\\svnerr.log >&2)
+  (& $env:PS_SC_DIR\svn.ps1 ci 1) 2> $logFilePath
+
+  if (!(Test-path $logFilePath) -or (cat $logFilePath | select-string "fail")) {
+    #cat $env:PS_SC_DIR\Conf\svnerr.log
+    Write-Host "Scripts not comitted!"
+    Write-Host "`nError log`n======================================================"
+    cat $logFilePath
+  }
+  else {
+    Write-Host "Upload success"
+    Write-Host "Shutting down shell.."
+    Start-Sleep -s 3
+
+    #Reference for $host exit: http://mshforfun.blogspot.com/2006/08/do-you-know-there-is-host-variable.html
+    $host.SetShouldExit(0)
+
+    <# Experiment
+    Write-Host "Press any key.. "
+    $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")     # reference: http://technet.microsoft.com/en-us/library/ff730938.aspx
+    Write-Host "You entered $x"
+    #>
+
+  }
 }
 
 function Main() {
-    UpdatePSProfile
-    
-    if ($cmd.Equals("skipsvn")) {
-        Write-Host "Ignoring SVN commit!"
-        Write-Host "Shutting down shell.."
-        Start-Sleep -s 3
-        $host.SetShouldExit(0)
-    }
-    else { PerformSVNCommit }
+  UpdatePSProfile
+  
+  if ($cmd.Equals("skipsvn")) {
+    Write-Host "Ignoring SVN commit!"
+    Write-Host "Shutting down shell.."
+    Start-Sleep -s 3
+    $host.SetShouldExit(0)
+  }
+  else { PerformSVNCommit }
 }
 # function definition ends
 
diff --git a/PowerShell/pdflatex.ps1 b/PowerShell/pdflatex.ps1
index b6e536c..f3cd55e 100644
--- a/PowerShell/pdflatex.ps1
+++ b/PowerShell/pdflatex.ps1
@@ -1,167 +1,167 @@
 <#
  # Date: 12/11/2012 16:13:11
- # Author: Saint Atique
+ # Author: Atiq
 
    New Usage EXamples:
-    $ 
-    $ .\pdflatex.ps1 CreatePDF "F:\svnws\All_Latex\Cover Letters\Moderncv Banking\job_gaming_se_cover_letter.tex"
-    $ .\pdflatex.ps1 cleantex "F:\svnws\All_Latex\Cover Letters\Moderncv Banking"
-    $ .\pdflatex.ps1 CreatePDF F:\svnws\All_Latex\Resume\SA_Resume_intern.tex
-    $ .\pdflatex.ps1 CreatePDF "F:\svnws\All_Latex\Data Mining\04_Milestone\sigproc-sp.tex" -hasRef yes
-    $ .\pdflatex.ps1 CreatePDF "F:\svnws\All_Latex\Data Mining\04_Milestone\sigproc-sp.tex" -perm elevate -ref yes
+  $ 
+  $ .\pdflatex.ps1 CreatePDF "F:\svnws\All_Latex\Cover Letters\Moderncv Banking\job_gaming_se_cover_letter.tex"
+  $ .\pdflatex.ps1 cleantex "F:\svnws\All_Latex\Cover Letters\Moderncv Banking"
+  $ . $env:PS_SC_DIR\pdflatex.ps1 CreatePDF main.tex
+  $ . $env:PS_SC_DIR\pdflatex.ps1 cleantex .
+  $ .\pdflatex.ps1 CreatePDF F:\svnws\All_Latex\Resume\SA_Resume_intern.tex
+  $ .\pdflatex.ps1 CreatePDF "F:\svnws\All_Latex\Data Mining\04_Milestone\sigproc-sp.tex" -hasRef yes
+  $ .\pdflatex.ps1 CreatePDF "F:\svnws\All_Latex\Data Mining\04_Milestone\sigproc-sp.tex" -perm elevate -ref yes
 
    Old Usage EXamples:
-    $ .\pdflatex.ps1 "F:\svnws\All_Latex\Data Mining\05_Final" sigproc-sp --noelevation --refcompile
-    $ .\pdflatex.ps1 F:\svnws\All_Latex\Resume SA_Resume_intern.tex --noelevation
-    $ .\pdflatex.ps1 "F:\Documents\English\Higher Study Docs\SOP\Latex" "Atiqur Rahman_SOP.tex"
+  $ .\pdflatex.ps1 "F:\svnws\All_Latex\Data Mining\05_Final" sigproc-sp --noelevation --refcompile
+  $ .\pdflatex.ps1 F:\svnws\All_Latex\Resume SA_Resume_intern.tex --noelevation
+  $ .\pdflatex.ps1 "F:\Documents\English\Higher Study Docs\SOP\Latex" "Atiqur Rahman_SOP.tex"
 #>
 
 #whenever epstopdf error occurs
 #$env:path += ";"+"C:\Program Files\MiKTex\miktex\bin\x64"
 
 Param(
-    [Parameter(Mandatory=$true)] [alias("a")] [string]$Action,
-    [Parameter(Mandatory=$true)] [alias("filepath")] [string]$texFilePath,
-    [Parameter(Mandatory=$false)] [alias("perm")] [string]$runAs,
-    [Parameter(Mandatory=$false)] [alias("ref")] [string]$hasRef)
+  [Parameter(Mandatory=$true)] [alias("a")] [string]$Action,
+  [Parameter(Mandatory=$true)] [alias("filepath")] [string]$texFilePath,
+  [Parameter(Mandatory=$false)] [alias("perm")] [string]$runAs,
+  [Parameter(Mandatory=$false)] [alias("ref")] [string]$hasRef)
 
 #######################################################################################################
-#####################       Functions' Definitions Start          #####################################
+#####################     Functions' Definitions Start      #####################################
 #######################################################################################################
 
 # Purpose of this function is to verify prerequisite program are installed and command line arguments are properly provided
 function VERIFY_PREREQUISITES_AND_PARAMETERS() {
-    if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
-        # MikTex installer is 32 bit, should have been installed in x86 directory
-        $global:pdflatexExec = 'D:\ProgramFiles\MikTex\miktex\bin\x64\pdflatex.exe'
-    }
+  if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
+    $global:pdflatexExec = $env:PFilesX64 + '\MiKTeX-2.9.6520\miktex\bin\x64\pdflatex.exe'
+  }
 	elseif ($HOST_TYPE.Equals("JASMINE_UNIVERSE_WS")) {
-        # MikTex installer is 32 bit, should have been installed in x86 directory
-        $global:pdflatexExec = "${env:ProgramFiles}\MikTex\miktex\bin\x64\pdflatex.exe"
-    }
-    elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
-        $global:pdflatexExec = 'C:\texlive\2014\bin\win32\pdflatex.exe'
+    $global:pdflatexExec = "${env:ProgramFiles}\MikTex\miktex\bin\x64\pdflatex.exe"
+  }
+  elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
+    $global:pdflatexExec = 'C:\texlive\2014\bin\win32\pdflatex.exe'
+  }
+
+  if ($Action.ToLower().Equals("createpdf")) {
+    # check if PdfLatex is installed in the system
+    # moved the condition here, want to run the script with cleantex without installing miktex
+    if (! (Test-Path $global:pdflatexExec)) {
+      write-host $global:pdflatexExec
+      Write-Host "PdfLatex script: please install Miktex latex and run again!`r`n"
+      return -1
     }
 
-    if ($Action.ToLower().Equals("createpdf")) {
-        # check if PdfLatex is installed in the system
-        # moved the condition here, want to run the script with cleantex without installing miktex
-        if (! (Test-Path $global:pdflatexExec)) {
-            write-host $global:pdflatexExec
-            Write-Host "PdfLatex script: please install Miktex latex and run again!`r`n"
-            return -1
-        }
-
-        # Add ".tex" if not provided
-        # file file name
-        if (! $texFilePath.EndsWith(".tex")) {
-            # inputText = inputText.Substring(0, inputText.LastIndexOf(item))
-            $texFilePath = $texFilePath + ".tex"
-        }
-        if (! (Test-Path -path $texFilePath -pathtype leaf)) {
-            Write-Host "Please provide correct source latex file path.`n"
-            return -1
-        }
-         
-        # Get only file name
-        $global:texWsDir = (Get-Item $texFilePath).Directory.FullName
-        $global:texFileName = $texFilePath.Replace($global:texWsDir+"\", "")
-
-        # file name
-        if ($global:texFileName.EndsWith(".tex")) {
-            # inputText = inputText.Substring(0, inputText.LastIndexOf(item))
-            $global:texFileName = $global:texFileName.Substring(0, $global:texFileName.LastIndexOf(".tex"))
-        }
-        $global:curTexFilePath = "`"${global:texWsDir}\${texFileName}.tex`""
-        $global:curpdfFilePath = $global:texWsDir + "\" + $texFileName + ".pdf"
-        $global:pdfName = $texFileName + ".pdf"
+    # Add ".tex" if not provided
+    # file file name
+    if (! $texFilePath.EndsWith(".tex")) {
+      # inputText = inputText.Substring(0, inputText.LastIndexOf(item))
+      $texFilePath = $texFilePath + ".tex"
     }
-    elseif ($Action.ToLower().Equals("cleantex")) {
-        # empty string check not required for mandatory parameter
-        if (! ( Test-Path $texFilePath) -Or (Test-Path -path $texFilePath -pathtype leaf)) {
-            Write-Host "Incorrect input directory `"$texFilePath`"`n"
-            return -1
-        }
-        # provided arguments correct
-        return 1
+    if (! (Test-Path -path $texFilePath -pathtype leaf)) {
+      Write-Host "Please provide correct source latex file path.`n"
+      return -1
     }
-    elseif ($Action.ToLower().Equals("open")) {
-        Write-Host -ForegroundColor Red "Not implemented!`n"
-        return -1
+     
+    # Get only file name
+    $global:texWsDir = (Get-Item $texFilePath).Directory.FullName
+    $global:texFileName = $texFilePath.Replace($global:texWsDir+"\", "")
+
+    # file name
+    if ($global:texFileName.EndsWith(".tex")) {
+      # inputText = inputText.Substring(0, inputText.LastIndexOf(item))
+      $global:texFileName = $global:texFileName.Substring(0, $global:texFileName.LastIndexOf(".tex"))
     }
-    else {
-        Write-Host -ForegroundColor Red "Incorrect action specified: `"$Action`"`n"
-        return -1
+    $global:curTexFilePath = "`"${global:texWsDir}\${texFileName}.tex`""
+    $global:curpdfFilePath = $global:texWsDir + "\" + $texFileName + ".pdf"
+    $global:pdfName = $texFileName + ".pdf"
+  }
+  elseif ($Action.ToLower().Equals("cleantex")) {
+    # empty string check not required for mandatory parameter
+    if (! ( Test-Path $texFilePath) -Or (Test-Path -path $texFilePath -pathtype leaf)) {
+      Write-Host "Incorrect input directory `"$texFilePath`"`n"
+      return -1
     }
-
-
-    $global:IsElevated = $false
-    if ((! $runAs.Equals("")) -and $runAs.Tolower().Equals("elevate")) {
-        $global:IsElevated = $true
-        $global:dirarg = "`"-output-directory=$global:texWsDir`""
-    }
-
-    $global:IsReferenced = $false
-    if ($hasRef.Equals(""))
-    {
-        Write-Host -ForegroundColor Green "Fast compilation: no reference"
-    }
-    elseif ($hasRef.Tolower().Equals("yes")) {
-        Write-Host -ForegroundColor Green "Reference compilation set"
-        $global:IsReferenced = $true
-        # $global:curBibFilePath = "`"${global:texWsDir}\${texFileName}.bib`""
-    }
-    elseif ($hasRef.Tolower().Equals("no")) {
-        Write-Host -ForegroundColor Green "Fast compilation: no reference"
-    }
-    else {
-        Write-Host -ForegroundColor Red "Invalid reference parameter: $hasRef. Please correct commandline and run again."
-        return -1
-    }
-    
+    # provided arguments correct
     return 1
+  }
+  elseif ($Action.ToLower().Equals("open")) {
+    Write-Host -ForegroundColor Red "Not implemented!`n"
+    return -1
+  }
+  else {
+    Write-Host -ForegroundColor Red "Incorrect action specified: `"$Action`"`n"
+    return -1
+  }
+
+
+  $global:IsElevated = $false
+  if ((! $runAs.Equals("")) -and $runAs.Tolower().Equals("elevate")) {
+    $global:IsElevated = $true
+    $global:dirarg = "`"-output-directory=$global:texWsDir`""
+  }
+
+  $global:IsReferenced = $false
+  if ($hasRef.Equals(""))
+  {
+    Write-Host -ForegroundColor Green "Fast compilation: no reference"
+  }
+  elseif ($hasRef.Tolower().Equals("yes")) {
+    Write-Host -ForegroundColor Green "Reference compilation set"
+    $global:IsReferenced = $true
+    # $global:curBibFilePath = "`"${global:texWsDir}\${texFileName}.bib`""
+  }
+  elseif ($hasRef.Tolower().Equals("no")) {
+    Write-Host -ForegroundColor Green "Fast compilation: no reference"
+  }
+  else {
+    Write-Host -ForegroundColor Red "Invalid reference parameter: $hasRef. Please correct commandline and run again."
+    return -1
+  }
+  
+  return 1
 }
 
 
 # Kill adobe pdf reader
 function KillPDFReader([string] $pdfReaderProgram, [string] $pdftitle) {
-    # Write-Host "got title: $pdftitle"
-    
-    if (Get-Process $pdfReaderProgram -ErrorAction SilentlyContinue) {
-        # $res = Get-Process $pdfReaderProgram -ErrorAction SilentlyContinue | where {$_.MainWindowTitle.Equals($pdftitle)}
-        $IsKilled = $false
-        do {
-            # Hint for accessing members http://www.computerperformance.co.uk/powershell/powershell_process_stop.htm
-            # Hint if we want this automated http://stackoverflow.com/questions/1777668/send-message-to-a-windows-process-not-its-main-window
-            # process class https://msdn.microsoft.com/en-us/library/system.diagnostics.process_properties(v=vs.110).aspx
-            $res = Get-Process $pdfReaderProgram -ErrorAction SilentlyContinue | where {$_.MainWindowTitle.ToString().StartsWith($pdftitle)}
-            <#foreach($p in $res) {
-                Write-Host "process`: `""$p.MainWindowTitle"`""
-            }#>
-
-            if ($res -eq $null) {
-                $response = Read-Host "Is there a process active? (if yes`: activate and press y)"
-
-                if ($response.Equals("n")) {
-                    $IsKilled = $true
-                    # Write-Host "You pressed" $response
-                    # $response | Get-Member
-                }
-            }
-            else {
-                Write-Host "Stopping Adobe Reader" $res.Id
-                # Stop-Process -Id $res.Id
-                # $res.Close()
-                $res.CloseMainWindow()
-                $IsKilled = $true
-            }
-
-        } while ($IsKilled -eq $false);
+  # Write-Host "got title: $pdftitle"
+  
+  if (Get-Process $pdfReaderProgram -ErrorAction SilentlyContinue) {
+    # $res = Get-Process $pdfReaderProgram -ErrorAction SilentlyContinue | where {$_.MainWindowTitle.Equals($pdftitle)}
+    $IsKilled = $false
+    do {
+      # Hint for accessing members http://www.computerperformance.co.uk/powershell/powershell_process_stop.htm
+      # Hint if we want this automated http://stackoverflow.com/questions/1777668/send-message-to-a-windows-process-not-its-main-window
+      # process class https://msdn.microsoft.com/en-us/library/system.diagnostics.process_properties(v=vs.110).aspx
+      $res = Get-Process $pdfReaderProgram -ErrorAction SilentlyContinue | where {$_.MainWindowTitle.ToString().StartsWith($pdftitle)}
+      <#foreach($p in $res) {
+        Write-Host "process`: `""$p.MainWindowTitle"`""
+      }#>
+
+      if ($res -eq $null) {
+        $response = Read-Host "Is there a process active? (if yes`: activate and press y)"
+
+        if ($response.Equals("n")) {
+          $IsKilled = $true
+          # Write-Host "You pressed" $response
+          # $response | Get-Member
         }
-    else {
-        # process is not running
-        Write-Host "Adobe Reader not found in ps list."
+      }
+      else {
+        Write-Host "Stopping Adobe Reader" $res.Id
+        # Stop-Process -Id $res.Id
+        # $res.Close()
+        $res.CloseMainWindow()
+        $IsKilled = $true
+      }
+
+    } while ($IsKilled -eq $false);
     }
+  else {
+    # process is not running
+    Write-Host "Adobe Reader process not found running."
+  }
 }
 
 <# not keeping preivious versions of pdf docs anymore
@@ -169,15 +169,15 @@ function KillPDFReader([string] $pdfReaderProgram, [string] $pdftitle) {
 $tmpFileName =  $texFileName + "_pre.pdf"
 $tmpFilePath = $texWsDir + "\" + $tmpFileName
 if (Test-Path $tmpFilePath) {
-    rm $tmpFilePath
-    Write-Host "Removed " $tmpFilePath
+  rm $tmpFilePath
+  Write-Host "Removed " $tmpFilePath
 }
 
 # rename current to previous
 if (Test-Path $curpdfFilePath) {
-    Start-Sleep 1
-    Rename-Item $curpdfFilePath $tmpFileName
-    Write-Host "Renamed " $curpdfFilePath " to " $tmpFileName
+  Start-Sleep 1
+  Rename-Item $curpdfFilePath $tmpFileName
+  Write-Host "Renamed " $curpdfFilePath " to " $tmpFileName
 }
 #>
 
@@ -188,156 +188,161 @@ if (Test-Path $curpdfFilePath) {
 #Write-Host "arg2: $dirarg"
 #& $global:pdflatexExec $curTexFilePath $dirarg
 function CreatePDFUsingMikTex() {
-    Push-Location
-    cd $global:texWsDir
-    if ($global:IsElevated) {
-        $argList=$global:curTexFilePath,$global:dirarg
-        
-        Write-Host "Final Commandline is: Start-Process $global:pdflatexExec -Verb Runas -ArgumentList $argList -ErrorAction `'stop`'"
-        try {
-            Start-Process $global:pdflatexExec -Verb Runas -ArgumentList $argList -ErrorAction 'stop'
-            # & $global:pdflatexExec H:\Higher_Study\CV\SA_CV_latex.tex -output-directory=H:\Higher_Study\CV
-        }
-        catch {
-            Write-Host -ForegroundColor Red "Permission denied. Exiting..`n"
-            Pop-Location
-            exit
-        }
-        Write-Host -NoNewline "`nWaiting for pdflatex to exit"
-        while (Get-Process pdflatex -ErrorAction SilentlyContinue) {
-            Write-Host -NoNewline "."
-            Sleep 1
-        }
+  Push-Location
+  cd $global:texWsDir
+  if ($global:IsElevated) {
+    $argList=$global:curTexFilePath,$global:dirarg
+    
+    Write-Host "Final Commandline is: Start-Process $global:pdflatexExec -Verb Runas -ArgumentList $argList -ErrorAction `'stop`'"
+    try {
+      Start-Process $global:pdflatexExec -Verb Runas -ArgumentList $argList -ErrorAction 'stop'
+      # & $global:pdflatexExec H:\Higher_Study\CV\SA_CV_latex.tex -output-directory=H:\Higher_Study\CV
     }
-    else {
-        # Write-Host "We are not elevated $global:dirarg`r`n"
-        if ($global:IsReferenced) { Write-Host -ForegroundColor Red "Do not run with `'-hasRef yes`' if you have an error in document.`r`n" }
-
-        if ($global:IsReferenced) {
-            if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
-                $bibtexExec = 'D:\ProgramFiles\MikTex\miktex\bin\x64\bibtex.exe'
-                $latexExec = 'D:\ProgramFiles\MikTex\miktex\bin\x64\latex.exe'
-            }
-            elseif ($HOST_TYPE.Equals("ORACLE_WS")) {
-                # MikTex installer 64 bit
-                $bibtexExec = "D:\ProgFiles_x64\MiKTeX 2.9\miktex\bin\x64\bibtex.exe"
-                $latexExec = "D:\ProgFiles_x64\MiKTeX 2.9\miktex\bin\x64\latex.exe"
-            }
-            elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
-                $bibtexExec = 'C:\texlive\2014\bin\win32\bibtex.exe'
-                $latexExec = 'C:\texlive\2014\bin\win32\pdflatex.exe'
-            }
-
-            Write-Host -ForegroundColor Green "Reference compilation: first run of latex"
-            & $latexExec $global:texFileName
-
-            # For disk IO, not sure if this is required
-            Start-Sleep -Milliseconds 5
-            #Write-Host -ForegroundColor Green "bib file path`: $global:texFileName"
-            Write-Host -ForegroundColor Green "`r`nFirst run of bibtex"
-            & $bibtexExec $global:texFileName
-            #Start-Sleep -Milliseconds 10
-            #popd
-            #exit
-            Start-Sleep -Milliseconds 5
-            Write-Host -ForegroundColor Green "`r`nSecond run of latex"
-            & $latexExec $global:texFileName
-            #Start-Sleep -Milliseconds 10
-            Start-Sleep -Milliseconds 5
-            # & $latexExec $curTexFilePath
-            Write-Host -ForegroundColor Green "`r`Final run of latex"
-        }
-        # Write-Host "$global:pdflatexExec $global:texFileName"
-        & $global:pdflatexExec $global:texFileName
-        Start-Sleep -Milliseconds 10
+    catch {
+      Write-Host -ForegroundColor Red "Permission denied. Exiting..`n"
+      Pop-Location
+      exit
+    }
+    Write-Host -NoNewline "`nWaiting for pdflatex to exit"
+    while (Get-Process pdflatex -ErrorAction SilentlyContinue) {
+      Write-Host -NoNewline "."
+      Sleep 1
     }
-    Pop-Location
-    Write-Host " "
+  }
+  else {
+    # Write-Host "We are not elevated $global:dirarg`r`n"
+    if ($global:IsReferenced) { Write-Host -ForegroundColor Red "Do not run with `'-hasRef yes`' if you have an error in document.`r`n" }
+
+    if ($global:IsReferenced) {
+      if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
+        $bibtexExec = 'D:\ProgramFiles\MikTex\miktex\bin\x64\bibtex.exe'
+        $latexExec = 'D:\ProgramFiles\MikTex\miktex\bin\x64\latex.exe'
+      }
+      elseif ($HOST_TYPE.Equals("ORACLE_WS")) {
+        # MikTex installer 64 bit
+        $bibtexExec = "D:\ProgFiles_x64\MiKTeX 2.9\miktex\bin\x64\bibtex.exe"
+        $latexExec = "D:\ProgFiles_x64\MiKTeX 2.9\miktex\bin\x64\latex.exe"
+      }
+      elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
+        $bibtexExec = 'C:\texlive\2014\bin\win32\bibtex.exe'
+        $latexExec = 'C:\texlive\2014\bin\win32\pdflatex.exe'
+      }
+
+      Write-Host -ForegroundColor Green "Reference compilation: first run of latex"
+      & $latexExec $global:texFileName
+
+      # For disk IO, not sure if this is required
+      Start-Sleep -Milliseconds 5
+      #Write-Host -ForegroundColor Green "bib file path`: $global:texFileName"
+      Write-Host -ForegroundColor Green "`r`nFirst run of bibtex"
+      & $bibtexExec $global:texFileName
+      #Start-Sleep -Milliseconds 10
+      #popd
+      #exit
+      Start-Sleep -Milliseconds 5
+      Write-Host -ForegroundColor Green "`r`nSecond run of latex"
+      & $latexExec $global:texFileName
+      #Start-Sleep -Milliseconds 10
+      Start-Sleep -Milliseconds 5
+      # & $latexExec $curTexFilePath
+      Write-Host -ForegroundColor Green "`r`Final run of latex"
+    }
+    # Write-Host "$global:pdflatexExec $global:texFileName"
+    & $global:pdflatexExec $global:texFileName
+    Start-Sleep -Milliseconds 10
+  }
+  Pop-Location
+  Write-Host " "
 }
 
 function OpenWithAdobePDFReader([string] $pdfFilePath) {
-    # open with adobe pdf reader
-    if (Test-Path $pdfFilePath) {
-        if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
-            # $adobeProg = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
-            $adobeProg = "D:\ProgramFiles_x86\Adobe\Reader 11.0\Reader\AcroRd32.exe"
-        }
-        elseif ($HOST_TYPE.Equals("JASMINE_UNIVERSE_WS")) {
-            # adobe reader 32 bit
-            $adobeProg = "${env:ProgramFiles(x86)}\Adobe\Reader 11.0\Reader\AcroRd32.exe"
-        }
+  # open with adobe pdf reader
+  if (Test-Path $pdfFilePath) {
+    if ($IsPDFReaderUWP) {
+      & $pdfFilePath
+      return
+    }
+    if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
+      # $adobeProg = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
+      $adobeProg = "D:\PFiles_x86\Adobe_Reader_11.0\Reader\AcroRd32.exe"
+    }
+    elseif ($HOST_TYPE.Equals("JASMINE_UNIVERSE_WS")) {
+      # adobe reader 32 bit
+      $adobeProg = "${env:ProgramFiles(x86)}\Adobe\Reader 11.0\Reader\AcroRd32.exe"
+    }
 
-        elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
-            $adobeProg = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
-        }
+    elseif ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
+      $adobeProg = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
+    }
 
-        if (Test-path $adobeProg) {
-            Write-Host "`rOpening output pdf file with Adobe Reader"
-            # Command line references 1
-            # 1. http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
-            # 2. http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/Acrobat_SDK_developer_faq.pdf
-            & $adobeProg /A "zoom=100=OpenActions" $pdfFilePath
-        }
+    if (Test-path $adobeProg) {
+      Write-Host "`rOpening output pdf file with Adobe Reader"
+      # Command line references 1
+      # 1. http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
+      # 2. http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/Acrobat_SDK_developer_faq.pdf
+      & $adobeProg /A "zoom=100=OpenActions" $pdfFilePath
     }
+  }
 }
 
 
-#####################      Function Definition Ends             #####################################
+#####################    Function Definition Ends       #####################################
 #######################################################################################################
 
 # Start of Main function
 function Main() {
-    $res = VERIFY_PREREQUISITES_AND_PARAMETERS
-    if ($res -le 0) {
-        # Write-Host "Returns $res`r`n"
-        break
-    }
-    if ($Action.ToLower().Equals("cleantex")) {
-        # Remove tex created files
-        $texWsDir = $texFilePath
-
-        $ExtList = "pdf","aux","log","out", "bbl", "blg", "dvi", "synctex.gz"
-
-        # Clean for tex
-        gci -Recurse $texWsDir\*.tex | %{
-            $FullPath = $_.fullName
-            $BarePath = $FullPath.Substring(0, $FullPath.LastIndexOf(".tex"))
-            $hasCleaned = $false
-
-            Foreach($ext in $ExtList) {
-                $ExtraTexFilePath = $BarePath+"."+$ext
-                if (Test-Path $ExtraTexFilePath) {
-                    Remove-Item -Force $ExtraTexFilePath
-                    $hasCleaned = $true
-                }
-            }
-            if ($hasCleaned) { Write-Host "Processed" $_.FullName }
-        }
-        Write-Host "For Tex files cleaned."
-        # Clean for tex
-        gci -Recurse $texWsDir\*.eps | %{
-            $FullPath = $_.fullName
-            $BarePath = $FullPath.Substring(0, $FullPath.LastIndexOf(".eps"))
-
-            $ExtraTexFilePath = $BarePath+"-eps-converted-to.pdf"
-            if (Test-Path $ExtraTexFilePath) {
-                Remove-Item -Force $ExtraTexFilePath
-                Write-Host "Processed" $_.FullName
-            }
-        }
-        Write-Host "For eps files cleaned."
-        $ExtraTexFilePath = $(Get-Location).Path + "\texput.log"
+  $res = VERIFY_PREREQUISITES_AND_PARAMETERS
+  if ($res -le 0) {
+    # Write-Host "Returns $res`r`n"
+    break
+  }
+  if ($Action.ToLower().Equals("cleantex")) {
+    # Remove tex created files
+    $texWsDir = $texFilePath
+
+    $ExtList = "pdf","aux","log","out", "bbl", "blg", "dvi", "synctex.gz"
+
+    # Clean for tex
+    gci -Recurse $texWsDir\*.tex | %{
+      $FullPath = $_.fullName
+      $BarePath = $FullPath.Substring(0, $FullPath.LastIndexOf(".tex"))
+      $hasCleaned = $false
+
+      Foreach($ext in $ExtList) {
+        $ExtraTexFilePath = $BarePath+"."+$ext
         if (Test-Path $ExtraTexFilePath) {
-            Remove-Item -Force $ExtraTexFilePath
-            Write-Host "Processed" $ExtraTexFilePath
+          Remove-Item -Force $ExtraTexFilePath
+          $hasCleaned = $true
         }
+      }
+      if ($hasCleaned) { Write-Host "Processed" $_.FullName }
+    }
+    Write-Host "For Tex files cleaned."
+    # Clean for tex
+    gci -Recurse $texWsDir\*.eps | %{
+      $FullPath = $_.fullName
+      $BarePath = $FullPath.Substring(0, $FullPath.LastIndexOf(".eps"))
+
+      $ExtraTexFilePath = $BarePath+"-eps-converted-to.pdf"
+      if (Test-Path $ExtraTexFilePath) {
+        Remove-Item -Force $ExtraTexFilePath
+        Write-Host "Processed" $_.FullName
+      }
     }
-    else {
-        # requires if you use adobe pdf reader to open the pdf file and the reader locks the file..
-        KillPDFReader AcroRd32 $global:pdfName
-        CreatePDFUsingMikTex
-        OpenWithAdobePDFReader $global:curpdfFilePath
+    Write-Host "For eps files cleaned."
+    $ExtraTexFilePath = $(Get-Location).Path + "\texput.log"
+    if (Test-Path $ExtraTexFilePath) {
+      Remove-Item -Force $ExtraTexFilePath
+      Write-Host "Processed" $ExtraTexFilePath
     }
+  }
+  else {
+    $script:IsPDFReaderUWP = $true
+    # requires if you use adobe pdf reader to open the pdf file and the reader locks the file..
+    KillPDFReader AcroRd32 $global:pdfName
+    CreatePDFUsingMikTex
+    OpenWithAdobePDFReader $global:curpdfFilePath
+  }
 }
 
 Main
diff --git a/PowerShell/ss.ps1 b/PowerShell/ss.ps1
index 71377f5..978db35 100644
--- a/PowerShell/ss.ps1
+++ b/PowerShell/ss.ps1
@@ -1,85 +1,88 @@
 <#
-    Argument problem fixed
-    use when number of arguments is more than one
-    $cargs = $args[1 .. ($args.Count)]
+  Argument problem fixed
+  use when number of arguments is more than one
+  $cargs = $args[1 .. ($args.Count)]
 
 #>
 
 param(
-    [parameter(Mandatory=$true)]
-    [string[]]$saArgs
+  [parameter(Mandatory=$true)]
+  [string[]]$saArgs
 )
 
 <#foreach ($elem in $saArgs){
-    $elem
+  $elem
 } 
 
 $saArgs = $args
 
 if ($saArgs.Count -lt 1) {
-    Write-Host "Please provide correct commandline"
+  Write-Host "Please provide correct commandline"
 }
 else {
-    Write-Host "we recieved" $saArgs.Count " number of cmd line args: " $saArgs
-    Write-Host "we recieved args as" $args.Count ":" $args
-    break
+  Write-Host "we recieved" $saArgs.Count " number of cmd line args: " $saArgs
+  Write-Host "we recieved args as" $args.Count ":" $args
+  break
 }
 #>
 
 <# Functions
-function RunProgramAsAdmin ([string]$progFile, [Switch]$Check) {    
-    # Check if script is running as Adminstrator and if not use RunAs 
-    # Use Check Switch to check if admin 
-     
-    # param([Switch]$Check) 
+function RunProgramAsAdmin ([string]$progFile, [Switch]$Check) {  
+  # Check if script is running as Adminstrator and if not use RunAs 
+  # Use Check Switch to check if admin 
+   
+  # param([Switch]$Check) 
+   
+  $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()` 
+    ).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") 
      
-    $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()` 
-        ).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") 
-         
-    if ($Check) { return $IsAdmin }     
+  if ($Check) { return $IsAdmin }   
  
-    if ($MyInvocation.ScriptName -ne "") 
-    {  
-        if (-not $IsAdmin)  
-        {  
-            try 
-            {  
-                # $arg = "-file `"$($MyInvocation.ScriptName)`"" 
-                Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'  
-            } 
-            catch 
-            { 
-                Write-Warning "Error - Failed to restart script with runas"  
-                break               
-            } 
-            exit # Quit this session of powershell 
-        }  
-    }  
-    else  
+  if ($MyInvocation.ScriptName -ne "") 
+  {  
+    if (-not $IsAdmin)  
     {  
-        Write-Warning "Error - Script must be saved as a .ps1 file first"  
-        break  
+      try 
+      {  
+        # $arg = "-file `"$($MyInvocation.ScriptName)`"" 
+        Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'  
+      } 
+      catch 
+      { 
+        Write-Warning "Error - Failed to restart script with runas"  
+        break         
+      } 
+      exit # Quit this session of powershell 
     }  
+  }  
+  else  
+  {  
+    Write-Warning "Error - Script must be saved as a .ps1 file first"  
+    break  
+  }  
 }#> 
 
 function ShowHelp {
-    Write-Host "`r`nSS`: Multi-purpose assistive command script"
-    Write-Host "==========================================================="
-    Write-Host "Following command line options are available:"
-    Write-Host "   cd`t`tGo to home dir"
-    Write-Host "   ep`t`tEdit profile"
-    Write-Host "   eh`t`tEdit hosts file"
-    Write-Host "   git-cmd`tCreate env for git"
-    Write-Host "   ise`t`tPowershell_ise editor"
-    Write-Host "   list-programs`tList available applications from app path"
-    Write-Host "   powershell`tRun powershell with administrator privilege"
-    Write-Host "   progname`tRun available application from app_path"
-    Write-Host "   python`tCreate env for python"
-    Write-Host "   winmerge`tStart file comparison utility"
-    Write-Host "   diffmerge`tStart alternative file comparison utility"
-    Write-Host "   luc`t`tLive USB Creator of Fedora"
-    Write-Host "   res--con`tResize console window dimension (Resize-Console)"
-    Write-Host "   help`t`tShow this help`n"
+  Write-Host "`r`nSS`: Multi-purpose assistive command script"
+  Write-Host "==========================================================="
+  Write-Host "Syntax for app path progs invocation,"
+  Write-Host "   start program arg1, arg2"
+  Write-Host "Following command line options are available:"
+  Write-Host "   cd`t`tGo to home dir"
+  Write-Host "   ep`t`tEdit profile"
+  Write-Host "   eh`t`tEdit hosts file"
+  Write-Host "   git-cmd`tCreate env for git"
+  Write-Host "   ise`t`tPowershell_ise editor"
+  Write-Host "   applist`tList available applications from app path"
+  Write-Host "   powershell`tRun powershell with administrator privilege"
+  Write-Host "   progname`tRun available application from app_path"
+  Write-Host "   python`tCreate env for python"
+  Write-Host "   winmerge`tStart file comparison utility"
+  Write-Host "   diffmerge`tStart alternative file comparison utility"
+  Write-Host "   luc`t`tLive USB Creator of Fedora"
+  Write-Host "   sgdm`t`tdiffmerge (SourceGear)"
+  Write-Host "   res--con`tResize console window dimension (Resize-Console)"
+  Write-Host "   help`t`tShow this help`n"
 }
 
 
@@ -95,323 +98,218 @@ $cmd = [string] $saArgs[0]
 # switch starts, alphabetical order
 # ss cd: go home
 if ($cmd.Equals("cd")) {
-    cd $env:PS_SC_DIR
-    break
+  cd $env:PS_SC_DIR
+  break
 }
 
 # ss ep: edit profile
 elseif ($cmd.Equals("ep")) {
-    Write-Host "File: $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1"
-    & $env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_ise.exe $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1
-    break
+  Write-Host "File: $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1"
+  & $env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_ise.exe $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1
+  break
 }
 
 elseif ($cmd.Equals("eh")) {
-    # npp might not be installed: take into account
-    # better way could be just try to check it from app paths
-    $NPPPATH = "${env:ProgramFiles(x86)}\notepad++\notepad++.exe"
-    $EditorProgram="notepad++"
-    $hostsFilePath = "$env:SystemRoot"+"\System32\drivers\etc\hosts"
-    if (-Not (Test-Path $NPPPATH) -Or (Get-Process $EditorProgram -ErrorAction SilentlyContinue)) {
-        # process is running
-        Write-Host "Please close existing $EditorProgram window and run the command again to open the file with notepad++. Or check if notepad++ is installed."
-        $EditorProgram="notepad"
-    }
-
-    Write-Host "Opening file $hostsFilePath for edit with admin privilege"
-    Try {
-        Start-Process $EditorProgram -Verb Runas -ArgumentList $hostsFilePath -ErrorAction 'stop'
-    }
-    Catch {
-        $_.Exception.Message
-    }
-    #& ss notepad++ $hostsFilePath
-
-    # notepad C:\Windows\System32\drivers\etc\hosts
-    # & $env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_ise.exe $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1
-    #>
+  # npp might not be installed: take into account
+  # better way could be just try to check it from app paths
+  $NPPPATH = "${env:ProgramFiles(x86)}\notepad++\notepad++.exe"
+  $EditorProgram="notepad++"
+  $hostsFilePath = "$env:SystemRoot"+"\System32\drivers\etc\hosts"
+  if (-Not (Test-Path $NPPPATH) -Or (Get-Process $EditorProgram -ErrorAction SilentlyContinue)) {
+    # process is running
+    Write-Host "Please close existing $EditorProgram window and run the command again to open the file with notepad++. Or check if notepad++ is installed."
+    $EditorProgram="notepad"
+  }
+
+  Write-Host "Opening file $hostsFilePath for edit with admin privilege"
+  Try {
+    Start-Process $EditorProgram -Verb Runas -ArgumentList $hostsFilePath -ErrorAction 'stop'
+  }
+  Catch {
+    $_.Exception.Message
+  }
+  #& ss notepad++ $hostsFilePath
+
+  # notepad C:\Windows\System32\drivers\etc\hosts
+  # & $env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_ise.exe $env:PS_SC_DIR\Microsoft.PowerShell_profile.ps1
+  #>
 }
 elseif ($cmd.Equals("powershell")) {
-    <#
-        This Powershell script pdflatex required inheriting following
-        $HOST_TYPE
-
-    #>
-    Write-Host "Opening file $hostsFilePath for edit with admin privilege"
-    Try {
-        Start-Process powershell -Verb Runas -ErrorAction 'stop'
-    }
-    Catch {
-        $_.Exception.Message
-    }
-    break
+  <#
+    This Powershell script pdflatex required inheriting following
+    $HOST_TYPE
+
+  #>
+  Write-Host "Opening file $hostsFilePath for edit with admin privilege"
+  Try {
+    Start-Process powershell -Verb Runas -ErrorAction 'stop'
+  }
+  Catch {
+    $_.Exception.Message
+  }
+  break
 }
 
 elseif ($cmd.Equals("cmd")) {
-    Write-Host "Starting elevated command prompt"
-    Start-Process cmd -Verb Runas -ErrorAction 'stop'
-    break
+  Write-Host "Starting elevated command prompt"
+  Start-Process cmd -Verb Runas -ErrorAction 'stop'
+  break
 }
 
 <# moved to host-network.ps1
 if ($cmd.Equals("hostnet")) {
-    Write-Host "Starting elevated command prompt with hosted network"
-    $argumentString = "/k " + $(get-location).path + "\hosted-network-assist-elevated.cmd"
-    Start-Process cmd -Verb Runas -ArgumentList $argumentString -ErrorAction 'stop'
-    break
+  Write-Host "Starting elevated command prompt with hosted network"
+  $argumentString = "/k " + $(get-location).path + "\hosted-network-assist-elevated.cmd"
+  Start-Process cmd -Verb Runas -ArgumentList $argumentString -ErrorAction 'stop'
+  break
 }#>
 
 # Live USB Creator
 if ($cmd.Equals("luc")) {
-    # Live USB creator requires correct working directory
-    $LUCProgramDir="C:\Program Files (x86)\LiveUSB Creator"
-    $LUCProgramName="liveusb-creator.exe"
-    # $hostsFilePath = "$env:SystemRoot"+"\System32\drivers\etc\hosts"
-    # Write-Host "Opening file $hostsFilePath for edit with admin privilege"
-    Start-Process -FilePath $LUCProgramName -WorkingDirectory $LUCProgramDir -Verb Runas -ErrorAction 'stop'
-    break
+  # Live USB creator requires correct working directory
+  $LUCProgramDir="C:\Program Files (x86)\LiveUSB Creator"
+  $LUCProgramName="liveusb-creator.exe"
+  # $hostsFilePath = "$env:SystemRoot"+"\System32\drivers\etc\hosts"
+  # Write-Host "Opening file $hostsFilePath for edit with admin privilege"
+  Start-Process -FilePath $LUCProgramName -WorkingDirectory $LUCProgramDir -Verb Runas -ErrorAction 'stop'
+  break
 }
 
 if ($cmd.Equals("help")) {
-    ShowHelp
-    break
-}
-
-# WinDiff is no more available
-# elseif ($cmd.ToLower().Equals("windiff")) {
-#    $SDKDIR = 'C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin'
-# Replacement is winmerge or diffmerge
-
-if ($cmd.Equals("mediainfo")) {
-    Write-Host "Starting Media Info"
-    # Now we have this for Windows Run Command to enable via Registry
-    $prog = "D:\PFiles_x64\PT\MediaInfo_GUI\MediaInfo.exe"
-    if (Test-Path $prog) {
-        & $prog
-    }
-    else { Write-Host "Program does not exist!" }
-    break
-}
-
-if ($cmd.Equals("windiff")) {
-    $wdiffPath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64"
-    if (Test-path $wdiffPath) {
-        $wdiffPath += "\WinDiff.Exe"
-        & $wdiffPath
-    }
-    else {
-        Write-Host "Windiff has been replaced by diffmerge or winmerge. Please try diffmerge."
-    }
-    break
+  ShowHelp
+  break
 }
 
 # ss ise: call powershell_ise editor
-if ($cmd.ToLower().Equals("ise")) {
-    $cargs = [string]$saArgs[1]
-    $VSPATH = $env:VS140COMNTOOLS + '..\..\..\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe'
-    $PSHELLISEPATH= $env:SystemRoot + '\System32\WindowsPowerShell\v1.0\powershell_ise.exe'
-    
-    $cpath = $cargs
-    # if the file 
-    if ($cargs.IndexOf("\") -eq "-1") {
-        $cpath =$(get-location).path+"\$cargs"
-    }
-    elseif ($cargs.StartsWith("..\")) {
-        $cpath =$(get-location).path
-        $cpath =$cpath.Substring(0, $cpath.LastIndexOf("\"))
-        $cpath +=$cargs.TrimStart("..")
-    } 
-    elseif ($cargs.StartsWith(".\")) {
-        $cpath =$(get-location).path+$cargs.TrimStart(".")
-    }
-    
-    if (Test-Path $cpath) {
-        # Write-Host "1. Path: $cpath"
-        & $VSPATH /Edit $cpath
-    }
-    else {
-        Write-Host "Creating File $cpath as it does not exist."
-        # New-Item $cpath -type file
-        "# Date: $(get-date)`n# Author: Atique`n"> $cpath
-        & $VSPATH /Edit $cpath
-    }
-    break
-}
-elseif ($cmd.ToLower().Equals("winmerge") -or $cmd.ToLower().Equals("diffmerge")) {
-    $DOUBLEARGPROGPATH = "${env:ProgramFiles(x86)}\WinMerge\WinMergeU.exe"
-    if ($cmd.ToLower().Equals("diffmerge")) {
-        $DOUBLEARGPROGPATH = 'X:\bin\SourceGear\Common\DiffMerge\sgdm.exe'
-        if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
-            $DOUBLEARGPROGPATH = 'D:\PFiles_x64\PT\DiffMerge-4.2\sgdm.exe'
-        }
-        elseif ($HOST_TYPE.Equals("ORACLE_WS")) {
-            $DOUBLEARGPROGPATH = "$env:ProgramFiles\SourceGear\Common\DiffMerge\sgdm.exe"
-        }
-    }
-    # winmerge
-    else {
-        if ($HOST_TYPE.Equals("PC_NOTEBOOK")) {
-            $DOUBLEARGPROGPATH = 'D:\PFiles_x86\PT\WinMerge\WinMergeU.exe'
-        }
-        # add condition for sinc site
-    }
-
-    if (!(Test-Path $DOUBLEARGPROGPATH)) {
-        Write-Host $DOUBLEARGPROGPATH
-        Write-Host "Program: $cmd is not installed!`n"
-        break
-    }
-<#
-if ($cmd.Equals("diffmerge")) {
-    $diffmergeEXEC = "C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe"
-    Write-Host "Starting $diffmergeEXEC"
-    & $diffmergeEXEC
-    break
-} #>
-    $carg1 = ""
-    $carg2 = ""
-    if ($saArgs.Count -eq 1) {
-        Write-Host "Starting windiff, file comparison utility: no command line argument provided."
-        & "$DOUBLEARGPROGPATH" 
-    }
-    elseif ($saArgs.Count -eq 2) {
-        $carg1 = [string]$saArgs[1]
-        Write-Host "Using single argument:" $carg1
-        if (! (Test-Path $carg1)) {
-            Write-Host "File doesn't exist. Please check file path."
-            break
-        }
-        Write-Host "Starting windiff, file comparison utility."
-        & "$DOUBLEARGPROGPATH" $carg1
-    }
-    elseif ($saArgs.Count -eq 3) {
-        $carg1 = [string]$saArgs[1]
-        $carg2 = [string]$saArgs[2]
-		Write-Host "arg1: $carg1"
-		Write-Host "arg2: $carg2"
-        if (! (Test-Path $carg1)) {
-            Write-Host "File 1: $carg1 doesn't exist."
-            break
-        }
-        if (! (Test-Path "$carg2")) {
-            Write-Host "File 2: $carg2 doesn't exist."
-            break
-        }
-        Write-Host "Starting windiff, file comparison utility."
-        & "$DOUBLEARGPROGPATH" $carg1 $carg2
-    }
-    else {
-        Write-Host "Invalid number of commmand line arguments! You provided " -nonewline
-        Write-Host $saArgs.count -nonewline
-        Write-Host " arguments."
-    }
-    break
-}
-elseif ($cmd.ToLower().Equals("divx") -or $cmd.ToLower().Equals("divxplusplayer")) {
-    $DIVXPlayerEXE = "C:\Program Files (x86)\DivX\DivX Plus Player\DivX Plus Player.exe"
-    if (Test-Path $DIVXPlayerEXE) {
-        & $DIVXPlayerEXE
-    }
-    break
-}
+# deprecated
+# use start devenv instead
+<# if ($cmd.ToLower().Equals("ise")) {
+  $cargs = [string]$saArgs[1]
+  $VSPATH = $env:PFilesX86 + '\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe'
+  $PSHELLISEPATH= $env:SystemRoot + '\System32\WindowsPowerShell\v1.0\powershell_ise.exe'
+  $EXEPATH = ''
+  if (Test-Path -PathType Leaf $VSPATH) {
+    $EXEPATH = $VSPATH
+  } else {
+    $EXEPATH = $PSHELLISEPATH
+  }
+
+  $cpath = $cargs
+  # if the file 
+  if ($cargs.IndexOf("\") -eq "-1") {
+    $cpath =$(get-location).path+"\$cargs"
+  }
+  elseif ($cargs.StartsWith("..\")) {
+    $cpath =$(get-location).path
+    $cpath =$cpath.Substring(0, $cpath.LastIndexOf("\"))
+    $cpath +=$cargs.TrimStart("..")
+  } 
+  elseif ($cargs.StartsWith(".\")) {
+    $cpath =$(get-location).path+$cargs.TrimStart(".")
+  }
+  
+  if (!(Test-Path $cpath)) {
+    Write-Host "Creating File $cpath as it does not exist."
+    "# Date: $(get-date)`n# Author: Atiq`n"> $cpath
+  }
+  if (Test-Path -PathType Leaf $VSPATH) {
+    & $EXEPATH /Edit $cpath
+  } else {
+    & $EXEPATH $cpath
+  }
+  break
+}#>
 # ss list-programs: list available registry programs
-elseif ($cmd.ToLower().Equals("list-programs")) {
-    ls "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
-    break
+elseif ($cmd.ToLower().Equals("applist")) {
+  gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
+  break
 }
 # Open Network Adapter Settings
 elseif ($cmd.ToLower().Equals("ncpa")) {
-    <# complete list of commands ref: http://pcsupport.about.com/od/tipstricks/a/control-panel-command-line.htm
-        1. window update: control wuaucpl.cpl
-        2. 
-    #>
-    control ncpa.cpl
-    break
-}
-# For skype
-elseif ($cmd.ToLower().Equals("skype")) {
-    $SkypeExec = ${env:ProgramFiles(x86)}+"\Skype\Phone\Skype.exe"
-    # & ${env:ProgramFiles(x86)}+"\Skype\Phone\Skype.exe"
-    & $SkypeExec
-    break
+  <# complete list of commands ref: http://pcsupport.about.com/od/tipstricks/a/control-panel-command-line.htm
+    1. window update: control wuaucpl.cpl
+    2. 
+  #>
+  control ncpa.cpl
+  break
 }
 # switch ends
 
 if ($saArgs.Count -gt 1) {
-    <# $cargs = [string] $saArgs
-    $cargs = $cargs.TrimStart($cmd)
-    $cargs = $cargs.TrimStart()
-    if ($cargs.StartsWith(".\")) {
-        $cargs = $cargs.TrimStart(".\")
-    } #>
-
-    $cargs = $args[1 .. ($args.Count)]
+  <# $cargs = [string] $saArgs
+  $cargs = $cargs.TrimStart($cmd)
+  $cargs = $cargs.TrimStart()
+  if ($cargs.StartsWith(".\")) {
+    $cargs = $cargs.TrimStart(".\")
+  } #>
+
+  $cargs = $args[1 .. ($args.Count)]
 }
 else {
-    $cargs = "";
+  $cargs = "";
 }
 
 $origcmd = $cmd
 
 if ($cmd.StartsWith(".\") -or $cmd.StartsWith("./")) {
-    $msgid += 1
+  $msgid += 1
 }
 elseif ($cmd.IndexOf("\") -eq "-1") {
-        $cmd = ".\" + $cmd
+    $cmd = ".\" + $cmd
 }
 
 #if ($cmd.EndsWith(".ps1") -or $cmd.EndsWith(".cmd") -or $cmd.EndsWith(".bat")) {
 if ($cmd.EndsWith(".ps1")) {
-    $msgid = $msgid + 2
+  $msgid = $msgid + 2
 }
 
 if ($HOST_TYPE.Equals("VSINC_SERVER_2008")) {
-    # check program list
-    $progs_list = @( "X:\bin\SourceGear\Common\DiffMerge\sgdm.exe", "X`:\bin\npp.6.7.7.bin\notepad++.exe", "X:\bin\WinRAR\WinRAR.exe")
-    
-    $app_exe = $cmd.Substring(2)+".exe"
-    # Write-Host "var we got: $app_exe"
-    # Write-Host "$cargs and $cmd"
-    foreach ($app in $progs_list) {
-        # Write-Host "app`: `"$app`""
-        if ((Test-Path $app) -and $app.ToLower().EndsWith($app_exe)) {
-            Write-Host "Starting local program`: `"$app`""
-            & "$app" $cargs
-            # Use exit instead of break because we are in a loop
-            exit
-        }
+  # check program list
+  $progs_list = @( "X:\bin\SourceGear\Common\DiffMerge\sgdm.exe", "X`:\bin\npp.6.7.7.bin\notepad++.exe", "X:\bin\WinRAR\WinRAR.exe")
+  
+  $app_exe = $cmd.Substring(2)+".exe"
+  # Write-Host "var we got: $app_exe"
+  # Write-Host "$cargs and $cmd"
+  foreach ($app in $progs_list) {
+    # Write-Host "app`: `"$app`""
+    if ((Test-Path $app) -and $app.ToLower().EndsWith($app_exe)) {
+      Write-Host "Starting local program`: `"$app`""
+      & "$app" $cargs
+      # Use exit instead of break because we are in a loop
+      exit
     }
-    # break
-    # should not come here!
-    # Write-Host "App does not exist!"
+  }
+  # break
+  # should not come here!
+  # Write-Host "App does not exist!"
 }
 if ($msgid -eq 0) {
-    # write.exe resolved a space was being added garbage
-    # $regitem = dir "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" -recurse -include *notepad* | Select-Object -first 1
-    # dir "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" -recurse -include *notepad* | Select-Object -first 1
-    $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$cmd.exe"
-    if (Test-Path $regPath) {
-        $regitem = Get-ItemProperty $regPath
-        # Get-ItemProperty $regPath
-        $regcmd = $regitem."(default)"
-        Write-Host "Starting program`: `"$regcmd`""
-        # Modify the command so that arguments don't get splitted
-        $regcmd = $regcmd.TrimStart("`"")
-        $regcmd = $regcmd.TrimEnd("`"")
-        & "$regcmd" $cargs
-        break
-    }
-    elseif (!(Test-Path "$env:PS_SC_DIR\$cmd.ps1")) {
-        Write-Host "Please check your command"
-        break
-    }
-    
+  # write.exe resolved a space was being added garbage
+  # $regitem = dir "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" -recurse -include *notepad* | Select-Object -first 1
+  # dir "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" -recurse -include *notepad* | Select-Object -first 1
+  $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$cmd.exe"
+  if (Test-Path $regPath) {
+    $regitem = Get-ItemProperty $regPath
+    # Get-ItemProperty $regPath
+    $regcmd = $regitem."(default)"
+    Write-Host "Starting program`: `"$regcmd`""
+    # Modify the command so that arguments don't get splitted
+    $regcmd = $regcmd.TrimStart("`"")
+    $regcmd = $regcmd.TrimEnd("`"")
+    & "$regcmd" $cargs
+    break
+  }
+  elseif (!(Test-Path "$env:PS_SC_DIR\$cmd.ps1")) {
+    Write-Host "Please check your command"
+    break
+  }
+  
 }
 elseif ($msgid -eq 1) {
-    Write-Host "* Spirited syntax"
+  Write-Host "* Spirited syntax"
 }
 elseif ($msgid -eq 3) {
-    Write-Host "* Spirited syntax *"
+  Write-Host "* Spirited syntax *"
 }
 
 & $env:PS_SC_DIR\$cmd $cargs
diff --git a/PowerShell/test.ps1 b/PowerShell/test.ps1
index d5dcaa2..2c4eb9f 100644
--- a/PowerShell/test.ps1
+++ b/PowerShell/test.ps1
@@ -1,3 +1,17 @@
+$installedapps = get-AppxPackage AdobeSystemsIncorporated.AdobeReader
+
+$aumidList = @()
+foreach ($app in $installedapps)
+{
+    foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id)
+    {
+        $aumidList += $app.packagefamilyname + "!" + $id
+    }
+}
+
+$aumidList
+
+
 <# $stream = [System.IO.StreamWriter] "e:\svnws\WordList\Barron Word DB format.txt"
 
 $FPath = "e:\svnws\WordList\Barron Word DB.txt"
diff --git a/PowerShell/winrar.ps1 b/PowerShell/winrar.ps1
index 67f22de..a982f76 100644
--- a/PowerShell/winrar.ps1
+++ b/PowerShell/winrar.ps1
@@ -96,7 +96,7 @@ function GetMediaName([string] $SFilePath, [string] $showType) {
 
     if ($showType.Equals('TVShow')) {
         # TV Show
-        $resMatch = ([regex] "(.*S\d\dE\d\d).(.*)(1080|720|brrip|BrRip|.)(.*)").Match($BaseName).Groups
+        $resMatch = ([regex] "(.*S\d\dE\d\d)(.*)(1080|720|brrip|BrRip|.*)(.*)").Match($BaseName).Groups
         # Season#, Episode#
         $seDesc = $resMatch[1].Value
         $title = $resMatch[2].Value
@@ -112,16 +112,18 @@ function GetMediaName([string] $SFilePath, [string] $showType) {
         {
             return $null
         }#>
+        $SubBaseName = $seDesc
         if (! [string]::IsNullOrEmpty($title)) {
             # $SubBaseName = $title1 + " " + $seDesc
             $SubBaseName = $title1 + $seDesc
         }
-        else {
-            $SubBaseName = $seDesc
-        }
+        # will fail for bare name S01E01.mp4
         Write-Host "TV Show name detected: $SubBaseName $title"
         $ParentDirPath = (Get-Item $SFilePath).Directory.FullName
         # this file might not exist, added a check
+        # appky this syntax gci D:\Movies\up_d\* -Include *.txt, *.gif
+        # process for multiples files returned in result
+        # [string]::Join(' ',(gci D:\Movies\up_d\* -Include *.txt, *.gif).FullName)
         $newMediaName = (Get-ChildItem "$ParentDirPath\$SubBaseName*.srt").FullName
         if ([string]::IsNullOrEmpty($newMediaName) -Or ! $newMediaName.EndsWith(".srt")) {
           $newMediaName = (Get-ChildItem "$ParentDirPath\$SubBaseName*.ass").FullName

Clone this wiki locally