Disabling UAC in Windows 11 using the registry

  1. Press Windows Key + R to open the Run dialog.
  2. Type regedit and press Enter.
  3. Navigate to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  1. In the right-hand pane, find the value named EnableLUA.
  2. Double-click on EnableLUA.
  3. Change the Value data from 1 to 0.
  4. Click OK to save the changes.
  5. Restart your computer for the changes to take effect.

Hide a User from the Windows Login Screen

Getting the exact username

  1. Press Windows Key + R to open the Run dialog.
  2. Type netplwiz and press Enter.
  3. The User Accounts window will list all user accounts on your Windows machine. The usernames are displayed in the “User name” column.

Using the Registry Editor

  1. Open the Registry Editor:

    • Press the Windows key + R.
    • Type “regedit” and press Enter.
  2. Navigate to the Winlogon Key:

    • Go to this path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
  3. Create SpecialAccounts and UserList Keys:

    • Right-click on “Winlogon” and select New -> Key. Name it SpecialAccounts.
    • Right-click on “SpecialAccounts” and select New -> Key. Name it UserList.
  4. Create a DWORD Value:

    • Right-click within the “UserList” key.
    • Select New -> DWORD (32-bit) Value.
    • Name the DWORD the exact username of the account you want to hide.
    • Double-click the new DWORD and set its value data to 0.
  5. Restart: Close the Registry Editor and restart your computer.

Deploy applications in Run as Administrator mode in Windows using Visual Studio and Inno Setup

Add the following line in your [Setup] section. This is the primary way to indicate that your installer requires administrative rights.

[Setup]
...
PrivilegesRequired=admin
...

Consider embedding an appropriate manifest into your application’s executable to have it automatically request elevation when executed outside the installer. This can provide a more seamless experience for the user.

1. Create the Manifest File:

  • Right-click on your project in the Solution Explorer and select Add -> New Item….
  • Choose Application Manifest File (it might be under the General category).
  • The default name is typically app.manifest. Keep this name or adjust it if necessary.

2. Modify the Manifest:

  • Open the newly created app.manifest file. The default content will be similar to this:

<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v1">
        </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>
  • Inside the <requestedPrivileges> element, add the following line:
<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

3. Embed the Manifest:

The manifest is now created, but you need to tell Visual Studio to embed it into your executable:

  • Right-click on your project and select Properties.
  • Go to the Application tab.
  • Under Manifest, select Embed manifest with default settings.

Build the Project:

Rebuild your project. The generated executable will now have the UAC manifest embedded, causing your application to request administrative privileges when run.

Handle Clipboard Paste in WPF

public YourWindow()
{
    InitializeComponent();

    // "yourTextBox" is your TextBox
    DataObject.AddPastingHandler(yourTextBox, OnPaste);
}

private void OnPaste(object sender, DataObjectPastingEventArgs e)
{
    var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true);
    if (!isText) return;

    var text = e.SourceDataObject.GetData(DataFormats.UnicodeText) as string;
    // Manipulate the text here
    text = text.Replace("oldValue", "newValue"); // Example manipulation

    // Set the new data
    e.DataObject = new DataObject(DataFormats.UnicodeText, text);
}

Note that this event is triggered after the user initiates the paste command but before the content is actually pasted into the TextBox, allowing you to modify or cancel the paste operation.

References
https://stackoverflow.com/questions/3061475/paste-event-in-a-wpf-textbox

Install chromedriver Automatically while using Selenium in C#

PM> Install-Package WebDriverManager
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;

namespace Test
{
    [TestFixture]
    public class Tests
    {
        private IWebDriver _webDriver;

        [SetUp]
        public void SetUp()
        {
            new DriverManager().SetUpDriver(new ChromeConfig());
            _webDriver = new ChromeDriver();
        }

        [TearDown]
        public void TearDown()
        {
            _webDriver.Quit();
        }

        [Test]
        public void Test()
        {
            _webDriver.Navigate().GoToUrl("https://www.google.com");
            Assert.True(_webDriver.Title.Contains("Google"));
        }
    }
}

References
https://github.com/rosolko/WebDriverManager.Net

Install chromedriver Automatically while using Selenium in Python

pip install webdriver-manager
service = Service(executable_path=ChromeDriverManager().install())
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--start-maximized")
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
# Add headless option
chrome_options.add_argument("--headless")
self.driver = webdriver.Chrome(options=chrome_options, service=service)