Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

06/11/2025

[Windows] Delete recovery partition

Windows disk manager lets you create, delete, modify partitions on connected drives, but does not allow deleting the recovery partition. To do that, you can use the diskpart utility which can be run from an Administator command line. The following commands will allow you to delete the partition, replace X with the desired disk and partition

diskpart

list disk

select disk X

list partition

select partition X

delete partition override


01/11/2025

[Windows 11] Disable lnk resolver

Windows has a set of features on NTFS file systems called "shortcut resolver" that allow the system to search for a shortcut target in the filesystem if it gets moved around after a link to it is created.

This is convenient normally in case you create a shortcut to something, then move said something somewhere else as usually the shortcut would stop working and throw an error when accessed instead. However, it can lead to security issues as a new attack vector is introduced that could allow a malicious actor to hijack the target and point to something unwanted instead.

The features can be disabled on Windows 11 by enabling some group policies (Start->Run->gpedit.msc):

  • User Configuration\Administrative Templates\Start Menu and Taskbar\Do not use the search-based method when resolving shell shortcuts
  • User Configuration\Administrative Templates\Start Menu and Taskbar\Do not use the tracking-based method when resolving shell shortcuts
  • User Configuration\Administrative Templates\Windows Components\File Explorer\Do not track shell shortcuts during roaming
Additionally the "Distributed Link Tracking Client" service can be disabled (Start->Run->services.msc)

06/08/2025

[Bing] Disable AI search clutter

AI is seemingly unescapable these days and annoying generated content is being shoved everywhere without consent.

To disable AI content clutter (copilot answers, video results, similar content and related searches) on Bing searches you can add a small rule to uBlock Origin extension under "My Filters" section:

www.bing.com##.b_ans

This will obviously break as soon as Microsoft pushes any update that changes the page content setup, however the workaround will be the same and will simply require finding out which element(s) to block.

uBlock Origin also has a very handy element picker mode that allows selecting a page component to create a rule to block it. Naturally the same can be achieved also by inspecting the page with Developer Tools (F12 usually) and finding the element tag(s) to block.

24/04/2025

[Windows 11] Uninstall widgets app

If you do not need the widgets functionality on your Windows machine, you can disable it from settings or completely remove it with:

winget uninstall "windows web experience pack"

[Windows] Hash a file

Windows offers a builtin tool to compute the hash of a file (example MD5):

CertUtil -hashfile FILENAME MD5

To view the list of supported options and hash algorithms:

CertUtil -hashfile -?

23/04/2025

[Windows 11] Disable telemetry and diagnostic data

Windows 11 collects some data and allows some configuration under Settings > Privacy & Security > Diagnostics & Feedback however you are not allowed to completely disable it. If you wanted to do so, you could apply a policy using the Local Group Policy Editor app (gpedit).

Find the Local Computer Policy > Administrative Templates > Windows Components > Data Collection and Preview Builds > Allow Diagnostic Data

Click to modify it, enable it and set it to "Diagnostic data off"

You can then logout and login again or run from a terminal the command to force reload policies:

gpupdate /force

[Windows 11] Remove PhoneLink app

Removing the PhoneLink app on Windows, is as easy as running (from administrator shell):

Get-AppxPackage Microsoft.YourPhone -AllUsers | Remove-AppxPackage

12/03/2025

[Windows 11] Initial setup without forced login

When setting up Windows 11 from a new installation, you will be guided through a graphical setup at boot. 

Since every other company decided to force onto users annoying choices without much backlash, also Microsoft though to participate in the fun now by forcing you to login to your Microsoft account (or create a new one) during this process.

To avoid this for the moment, you can run a couple commands during the setup. After choosing the language for the setup process, press SHIFT+F10 to open a command prompt, then enter:

OOBE\BYPASSNRO

which will make the PC reboot. Once you are back into the setup process, choose the language again (if prompted) and press again SHIFT+F10 to get back into the command prompt, this time enter:

ipconfig /release

to disconnect from any network you might be connected to.

Finally moving forward in the process, when you reach the "connect to the internet" stage, you will have the option to click on a small link saying "I don't have internet", you will then be prompted to create a local account on your PC.

09/11/2023

[Windows 11] Default show more options explorer right click menu (old UI behavior)

One change with Windows 11 is that the right click menu in Explorer was replaced with some condensed version where the old behavior is hidden behind a "Show more options" entry. This makes some actions slower to find and quite annoying, for example 7-zip or Notepad++

To revert it to the nicer old UI you can add a personal registry key, by typing this in a command prompt:

reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve

Then logout and login again or restart explorer process to see the effect take place.

This is setting an override on the default config found under (which remains untouched):

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InProcServer32

To undo the change, simply delete the registry key created by the command.

06/11/2023

[Tampermonkey] Disable Bing Chat search integrations

When using Bing search there are multiple places that integrate the Chat functionality with the ChatGPT AI. Some of these integrations are annoying and can be easily disabled by installing the Tampermonkey browser extension then adding a couple scripts to modify the displayed webpage and its behavior.

 // ==UserScript==  
 // @name    Disable Bing Search Engine Scroll  
 // @namespace  your-namespace  
 // @description Disables scrolling on the Bing search engine page to prevent accidental scrolling into the Bing chat feature.  
 // @match   https://www.bing.com/*  
 // @version   1  
 // @grant    none  
 // ==/UserScript==  
   
 window.addEventListener("wheel", e=>{  
 if(e.target.className.includes("cib-serp-main")) e.stopPropagation();  
 });  

  • Disable sidebar Chat autosearch functionality when disaplying search results:
 // ==UserScript==  
 // @name    Disable Bing Chat autosearch  
 // @namespace  your-namespace  
 // @description Disables the Bing Chat autosearch functionality on the right side of results when doing a search.  
 // @match   https://www.bing.com/*  
 // @version   1  
 // @grant    none  
 // ==/UserScript==  
   
 const element = document.getElementById("sydwrap_wrapper");  
 element.remove();  
 const element1 = document.getElementById("b_sydTigerCont");
 element1.remove();

Remember that of course these scripts might stop working one day if Microsoft decides to change something on their side, when that happens they will simply need to be updated.

21/04/2020

[Windows] Share environment variables in Windows Subsystem for Linux

Now that you have your fancy WSL up and running, you want to use it and all your environment variables are NOT available (of course).

Luckily there is a workaround, using the WSLENV variable. Unfortunately, it is not a direct 1:1 translation of your existing variables, rather you will need to craft them manually and convert between the two environments before you run a command or switch environment.

For example, to pass your JAVA_HOME correctly to wsl:

set JAVA_HOME=%JAVA_HOME%
set WSLENV=JAVA_HOME/up
wsl
echo $JAVA_HOME

And the magic is behind that last /up flag which says: set the value when invoking WSL from Windows (u) and translate between Windows and Unix paths (p)

WARNING: spaces are NOT escaped
WARNING2: only ONE variable is shared, so you cannot share both JAVA_HOME and PATH for example at the same time

[Windows] Activate and configure Windows Subsystem for Linux

Windows 10 introduced an update that adds a very cool feature: Windows Subsystem for Linux. If you are a fan of Cygwin, or similar tools, you will greatly like this feature as well.

Setup could be a bit more straightforward, but still not a big issue:

  1. Enable Windows Subsystem for Linux as a Windows feature from Control Panel > Programs and Features > Turn Windows features on or off
  2. Reboot
  3. Make sure LxssManager service is running
  4. Install a Linux distro from Windows store, search for "WSL" and pick the one you prefer, for example Alpine or Ubuntu, if no distro is installed, you get an error instead:
Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Windows Store: https://aka.ms/wslstore Press any key to continue...

And going to that link brings you nowhere.. so just install it yourself from the store.

After the installation is completed (might ask you to setup a user and password), you can open any command prompt and type wsl to launch it.

Be careful, that command was different in the past: lxrun or bash and there are apparently 2 versions of WSL as well, use whatever makes it run for you

17/04/2020

[Windows] Store command output in variable in batch script

For whatever reason, storing the output of a command into a variable from a batch script is not easy at all:

FOR /F "tokens=*" %%g IN ('your_command ^| with_escaped_pipe_if_you_need_it') do (SET VAR=%%g)

18/03/2019

[Ubuntu] Install Microsoft fonts

Most of the world uses Microsoft Windows and Office, therefore it might be sometimes necessary to generate documents using Microsoft fonts, which of course are only available on Windows.

For Ubuntu, the ttf-mscorefonts-installer package contains SOME of those fonts, simply install it and you can start using them AFTER regenerating the font cache with fc-cache

20/03/2017

[SQL] Excel COUNTIFS - count columns matching criteria in a row

Excel in his arsenal of useful functions has COUNTIFS, basically a count of how many elements in a one dimensional range match a specific criteria. It says multidimensional, but it's not, it's either the same criteria twice for more dimensions or a different criteria. Key point: one list at a time.

However this is a very basic need which is not immediately achievable in SQL as well since we cannot loop over columns in a row. That is, unless we remember that PIVOTing is actually a thing. In this specific case we use the inverse operation, UNPIVOT.

28/02/2016

[VBA] Excel open popup from macro

As usual when dealing with business users, you'll find yourself tinkering with Excel files which could include macros.

As usual when business users try their hands at this newfangled tech stuff, they will end up putting in a minuscule yet showstopping mistake you need to spot.

Although the VBA debugger is actually pretty good, sometimes the error is just stemming from a wrong value being inserted in a cell. In this case, it's just faster to simply display the value(s) in a popup window and then searhing for the offending cell in the spreadsheet.

The MsgBox function alongside with the CStr one will become your new best friends here:

MsgBox ("I am putting this value " & CStr(your_value) & " but maybe it is wrong")

Where & is used to concatenate strings and your_value can be a variable or an expression within the macro you're debugging.

07/11/2015

[TIBCO Spotfire] Excel JDBC data source template

If you want to take full advantage of the Information Designer capabilities when connecting to non-default data sources, and your analysis can't be fully developed using only Connectors and/or ADS, you might want to create your own data source template. [1]

The idea is simple: as long as you have a proper JDBC driver and can supply basic details on how to connect and handle operations, Spotfire Server allows you to add a custom connection template that end users will be able to select when creating a new Data Source. [2]

Here is a sample connection template for Excel. Note that in this case you will need the ODBC driver as well.

 <jdbc-type-settings>   
  <!-- Informative name and display-name -->   
  <type-name>ODBC-EXCEL</type-name>   
  <!-- point out the JDBC-ODBC bridge -->   
  <driver>sun.jdbc.odbc.JdbcOdbcDriver</driver>   
  <!-- Pattern displayed to administrator when setting up the Datasource -->   
  <connection-url-pattern>jdbc:odbc:excel-odbc-source</connection-url-pattern>   
  <!-- Table types allowed for EXCEL is TABLE and SYSTEM TABLE -->   
  <table-types>TABLE, SYSTEM TABLE</table-types>   
  <!-- As ping command we will use the integer constant 1. Could really be any pseudo function. -->   
  <ping-command>SELECT 1</ping-command>   
  <connection-properties />   
  <!-- Excel does not support catalogs nor schemas -->   
  <supports-catalogs>false</supports-catalogs>   
  <supports-schemas>false</supports-schemas>   
  <!-- Found an error in excel not allowing Distinct in combination with order-by on all columns. -->   
  <!-- Choice between supporting order by and distinct in favor for distinct -->   
  <!-- to make prompt without duplicates and support distinct conditioning. -->   
  <supports-order-by>false</supports-order-by>   
  <!-- Format pattern for date, time and datetime (same as timestamp). -->   
  <date-literal-format-expression>{d '$$value$$'}</date-literal-format-expression>   
  <time-literal-format-expression>{t '$$value$$'}</time-literal-format-expression>   
  <date-time-literal-format-expression>{ts '$$value$$'}</date-time-literal-format-expression>   
  </jdbc-type-settings>   


[1] Data source template documentation - Chapter 11.5
[2] Sample guidelines to add Attivio as data source

24/05/2014

[Windows] Scan hosts for open ports without Telnet with PortQry

When testing a connection, you'll probably want to check if a particular port is reachable on the destination host. Telnet is fine enough for this task:

telnet host port

but unfortunately, Windows comes with the Telnet client disabled by default. Since enabling it requires you to have Administrator privileges, an alternative is to use Microsoft PortQry which is a command line tool with no installation required.

After downloading and extracting it, you can run it as:

portqry -n host -e port

14/02/2014

[Microsoft Access] UPDATE table SELECT FROM nested query

For those of you forced to use Microsoft Access, thus needing to write bad SQL, here's how you would write an UPDATE table SELECT FROM subquery statement:

UPDATE A, B
SET A.column = B.column
WHERE A.key = B.key

which is equal to SQL's:

UPDATE A
SET column = (
        SELECT B.column
        FROM B
        WHERE A.key = B.key)

24/12/2013

[Windows] Install WIM images with ImageX

To perform quick Windows installations or reinstalls, if you have .wim images, you may use the ImageX application.

You'll firstly need to copy the ImageX files on a bootable USB drive - or whatever you prefer - and the .wim images on a support accessible from your PC at boot time (network drive, system partition, USB disk, etc...)

Now reboot the system and configure the bootloader to load the ImageX support first; you'll be brought to a command line shell you can interact with.
Note: If you need to alter the disk partitioning, run the diskpart command first.

To install the image(s) simply run the following command:

PATH_TO_IMAGEX_DRIVE\imagex.exe /apply PATH_TO_IMAGES\IMAGE_NAME WIM_VOLUME_NUMBER DRIVE_LETTER

eg:

G:\imagex.exe /apply H:\images\win7.wim 1 C:\

Copying the image onto the specified destination may take some time, so just sit back and wait. Here's a full list of ImageX's command line options.