diff --git a/CCPCryptFS Install.ps1 b/CCPCryptFS Install.ps1 deleted file mode 100644 index 6adf6e5..0000000 --- a/CCPCryptFS Install.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -$releaseURL = "https://api.github.com/repos/bailey27/cppcryptfs/releases/latest" -$installPath = "C:\Program Files\CCPCryptFS" - -$release = Invoke-RestMethod $releaseURL -$latestVersion = $release.tag_name -write-host "Latest Version: $latestVersion" - -new-item -type Directory $installPath -force | out-null - -foreach ($asset in $release.assets) { - $fileName = $asset.name - $downloadURL = $asset.browser_download_url - if ($fileName -like '*32.exe') { - continue - } - - Invoke-WebRequest -URI $downloadURL -OutFile "$installPath\$fileName" - - if ($fileName -like 'cppcryptfs.exe') { - $WScriptShell = New-Object -ComObject WScript.Shell - $Shortcut = $WScriptShell.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\$((Get-Item "$installPath\$fileName").Basename).lnk") - $Shortcut.TargetPath = "$installPath\$fileName" - $Shortcut.Save() - } - -} \ No newline at end of file diff --git a/Install CCPCryptFS.ps1 b/Install CCPCryptFS.ps1 new file mode 100644 index 0000000..0e6896a --- /dev/null +++ b/Install CCPCryptFS.ps1 @@ -0,0 +1,67 @@ +[cmdletbinding()] +Param () +##################### +# Get Admin Rights ## +##################### + +# Get the ID and security principal of the current user account +$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() +$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID) + +# Get the security principal for the Administrator role +$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator + +# Check to see if we are currently running "as Administrator" and not 64 bit +if ($myWindowsPrincipal.IsInRole($adminRole)) { + # We are running "as Administrator" - so change the title and background color to indicate this + $Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)" + #$Host.UI.RawUI.BackgroundColor = "DarkBlue" + clear-host +} else { + # We are not running "as Administrator" - so relaunch as administrator + # Create a new process object that starts PowerShell x86 + # Check to see if we are currently running x86 arch + # the LHO script can only run with 32 bit powershell + if (([environment]::Is64BitProcess)) { + # run the 32 bit powershell exe when on a 64 bit computer + $newProcess = new-object System.Diagnostics.ProcessStartInfo "C:\Windows\SysWoW64\WindowsPowerShell\v1.0\powershell.exe"; + } else { + # run the normal 32 bit powershell exe when on 32 bit computer + $newProcess = new-object System.Diagnostics.ProcessStartInfo "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe"; + } + # Specify the current script path and name as a parameter with added scope and support for scripts with spaces in it's path + $newProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'" + # Indicate that the process should be elevated + $newProcess.Verb = "runas"; + # Start the new process + [System.Diagnostics.Process]::Start($newProcess); + # Exit from the current, unelevated, process + exit +} + +$releaseURL = "https://api.github.com/repos/bailey27/cppcryptfs/releases/latest" +$installPath = "C:\Program Files\CCPCryptFS" + +$release = Invoke-RestMethod $releaseURL +$latestVersion = $release.tag_name +write-host "Latest Version: $latestVersion" + +new-item -type Directory $installPath -force | out-null + +foreach ($asset in $release.assets) { + $fileName = $asset.name + $downloadURL = $asset.browser_download_url + if ($fileName -like '*32.exe') { + continue + } + + Invoke-WebRequest -URI $downloadURL -OutFile "$installPath\$fileName" + + if ($fileName -like 'cppcryptfs.exe') { + $WScriptShell = New-Object -ComObject WScript.Shell + $Shortcut = $WScriptShell.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\$((Get-Item "$installPath\$fileName").Basename).lnk") + $Shortcut.TargetPath = "$installPath\$fileName" + $Shortcut.Save() + } + +} \ No newline at end of file