суббота, 26 августа 2023 г.

Disable Edge Browser Initial Questions

 cls


# Parameters

$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge"

$registryName = "HideFirstRunExperience"

$registryValue = 1


# Function to disable Edge initial questions

function Disable-EdgeFirstRunExperience {

    # Check if the registry key exists

    if (-Not (Test-Path $registryPath)) {

        # Create the registry key if it doesn't exist

        New-Item -Path $registryPath -Force

    }


    # Set the registry value to disable the first-run experience

    Set-ItemProperty -Path $registryPath -Name $registryName -Value $registryValue

}


# GUI Design

Add-Type -AssemblyName System.Windows.Forms

$form = New-Object System.Windows.Forms.Form

$form.Text = "Disable Edge Initial Questions"

$form.Size = New-Object System.Drawing.Size(300,150)

$form.StartPosition = "CenterScreen"


$button = New-Object System.Windows.Forms.Button

$button.Location = New-Object System.Drawing.Point(75,40)

$button.Size = New-Object System.Drawing.Size(150,30)

$button.Text = "Disable Questions"

$button.Add_Click({

    Disable-EdgeFirstRunExperience

    [System.Windows.Forms.MessageBox]::Show("Edge initial questions have been disabled.", "Success")

})

$form.Controls.Add($button)


$form.ShowDialog()


Set new WINS in Windows with PoSH GUI script

It is a good GUI script which checks if the new WINS IP is the same as the previous, and checks if the IP is kosher. You can't use 1.2.3.4.5.6 or 900.900.900.900 or 10.10, for example.


cls


# Load necessary assemblies for GUI

Add-Type -AssemblyName System.Windows.Forms


# Function to get current WINS IP

Function GetCurrentWINS {

    $currentWinsInfo = netsh interface ip show config "Ethernet" | Select-String "WINS"

    $currentWinsIP = if ($currentWinsInfo) { ($currentWinsInfo -split ":")[1].Trim() } else { "Not Set" }

    return $currentWinsIP

}


# Function to validate IP address

Function Validate-IPAddress {

    param (

        [string]$IPAddress

    )

    return ([System.Net.IPAddress]::TryParse($IPAddress, [ref]0))

}


# Initial Old WINS IP

$oldWINS = GetCurrentWINS


# Create the main form

$form = New-Object System.Windows.Forms.Form

$form.Text = "Set WINS IP Address"

$form.Size = New-Object System.Drawing.Size(400, 250)

$form.StartPosition = "CenterScreen"

$form.BackColor = [System.Drawing.Color]::LightBlue


# Create a GroupBox for Old WINS IP

$groupOld = New-Object System.Windows.Forms.GroupBox

$groupOld.Text = "Old WINS IP for adapter `Ethernet`:"

$groupOld.Location = New-Object System.Drawing.Point(10, 10)

$groupOld.Size = New-Object System.Drawing.Size(370, 50)

$form.Controls.Add($groupOld)


# Create a label for Old WINS IP address

$labelOldWINS = New-Object System.Windows.Forms.Label

$labelOldWINS.Text = $oldWINS

$labelOldWINS.AutoSize = $true

$labelOldWINS.Location = New-Object System.Drawing.Point(10, 20)

$groupOld.Controls.Add($labelOldWINS)


# Create a text box for WINS IP address input

$textBoxWINS = New-Object System.Windows.Forms.TextBox

$textBoxWINS.Location = New-Object System.Drawing.Point(10, 70)

$textBoxWINS.Size = New-Object System.Drawing.Size(260, 20)

$textBoxWINS.Text = GetCurrentWINS

$textBoxWINS.Add_KeyDown({

    if ($_.KeyCode -eq 'Enter') {

        $buttonSet.PerformClick()

    }

})

$form.Controls.Add($textBoxWINS)


# Create a GroupBox for New WINS IP

$groupNew = New-Object System.Windows.Forms.GroupBox

$groupNew.Text = "New WINS IP for adapter `Ethernet`:"

$groupNew.Location = New-Object System.Drawing.Point(10, 100)

$groupNew.Size = New-Object System.Drawing.Size(370, 50)

$form.Controls.Add($groupNew)


# Create a label for displaying the new WINS IP

$labelNewWINS = New-Object System.Windows.Forms.Label

$labelNewWINS.AutoSize = $true

$labelNewWINS.Location = New-Object System.Drawing.Point(10, 20)

$groupNew.Controls.Add($labelNewWINS)


# Create a button to set the WINS IP address

$buttonSet = New-Object System.Windows.Forms.Button

$buttonSet.Text = "Set WINS IP"

$buttonSet.Location = New-Object System.Drawing.Point(280, 70)

$buttonSet.Add_Click({

    $newWINS = $textBoxWINS.Text

    if (Validate-IPAddress $newWINS) {

        if ($newWINS -eq $oldWINS) {

            $labelNewWINS.Text = "IP is the same as Old WINS. No changes made."

        } else {

            netsh interface ip set wins "Ethernet" static $newWINS

            $labelNewWINS.Text = $newWINS

            $oldWINS = $newWINS

        }

    } else {

        $labelNewWINS.Text = "Invalid IP address. No changes made."

    }

})

$form.Controls.Add($buttonSet)


# Create an Exit button

$buttonExit = New-Object System.Windows.Forms.Button

$buttonExit.Text = "Exit"

$buttonExit.Location = New-Object System.Drawing.Point(280, 160)

$buttonExit.Add_Click({

    $form.Close()

})

$form.Controls.Add($buttonExit)


# Show the form

$form.ShowDialog()