Skip to content

Commit

Permalink
Set Env Vars
Browse files Browse the repository at this point in the history
  • Loading branch information
JDeepD committed Nov 3, 2023
1 parent 005491c commit eafc7ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Currently only made for NIT Silchar.

#### Download binary from [here](https://github.com/JDeepD/fpx/releases).
#### Download the latest binary from [here](https://github.com/JDeepD/fpx/releases).

## Usage? (Its as simple as it gets)
https://github.com/JDeepD/fpx/assets/64089730/8f16439e-e821-4db8-b0f2-38bece5311bb
Expand All @@ -19,3 +19,7 @@ https://github.com/JDeepD/fpx/assets/64089730/8f16439e-e821-4db8-b0f2-38bece5311
- [ ] Make Proxy Configuration Customisable
- [ ] UI Improvments

## Common Issues:

1. Make sure `git` and `nodejs` are in the path for their proxy configurations to change.
2. [Drop an Issue](https://github.com/JDeepD/fpx/issues) in the Issues section if you face some bugs.
30 changes: 15 additions & 15 deletions fpx-nits.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,29 @@ function setproxy {
param (
[string]$proxyserver
)
$envSetupScript = {
# Set environment variable (Machine)
[System.Environment]::SetEnvironmentVariable('http_proxy',$proxyserver, [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable('https_proxy',$proxyserver, [System.EnvironmentVariableTarget]::Machine)
}
git config --global http.proxy $proxyserver
git config --global https.proxy $proxyserver
npm config set proxy $proxyserver
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name 'ProxyServer' -Value $proxyserver
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name 'ProxyEnable' -Value 1
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$envSetupScript`" -Verb RunAs" -WindowStyle Hidden
$job = Start-Job -ScriptBlock {
param (
$variableValue
)
[Environment]::SetEnvironmentVariable('http_proxy', $variableValue, [System.EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable('https_proxy', $variableValue, [System.EnvironmentVariableTarget]::User)
} -ArgumentList $proxyserver
}

function unsetproxy {
$envSetupScript = {
# Unset environment variable (Machine)
[System.Environment]::SetEnvironmentVariable('http_proxy','',[System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable('https_proxy','',[System.EnvironmentVariableTarget]::Machine)
}
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config -g rm proxy
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name 'ProxyEnable' -Value 0
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$envSetupScript`" -Verb RunAs" -WindowStyle Hidden
$job = Start-Job -ScriptBlock {
[Environment]::SetEnvironmentVariable('http_proxy', '', [System.EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable('https_proxy', '', [System.EnvironmentVariableTarget]::User)
}
}

function updateproxy {
Expand All @@ -71,24 +70,25 @@ $FormMain.Width = 400
$FormMain.Height = 200
$FormMain.AutoSize = $false


$info = New-Object Windows.Forms.Label
$info.Location = New-Object Drawing.Point(20, 140)
$info.Font = New-Object Drawing.Font("Arial", 10, [System.Drawing.FontStyle]::Bold) # Set font size to 14
$info.Font = New-Object Drawing.Font("Arial", 10, [System.Drawing.FontStyle]::Bold)
updateproxy
$info.AutoSize = $true
$FormMain.Controls.Add($info)

$label = New-Object Windows.Forms.Label
$label.Location = New-Object Drawing.Point(20, 20)
$label.Text = "Select a Proxy:"
$label.Font = New-Object Drawing.Font("Arial", 10, [System.Drawing.FontStyle]::Bold) # Set font size to 14
$label.Font = New-Object Drawing.Font("Arial", 10, [System.Drawing.FontStyle]::Bold)
$label.AutoSize = $true
$FormMain.Controls.Add($label)

$comboBox = New-Object Windows.Forms.ComboBox
$comboBox.Location = New-Object Drawing.Point(20, 50)
$comboBox.Width = 350
$comboBox.Font = New-Object Drawing.Font("Arial", 12, [System.Drawing.FontStyle]::Regular) # Set font size to 12
$comboBox.Font = New-Object Drawing.Font("Arial", 12, [System.Drawing.FontStyle]::Regular)
$comboBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList

foreach ($proxy in $ProxyList) {
Expand Down

0 comments on commit eafc7ed

Please sign in to comment.