Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

17 April 2026

windows equivalents for popular unix commands

Some Windows cmd equivalents for common Unix commands and settings for my onw reference

unix cmd
powershell
echo $variable echo %variable% $variable
$env:variable //environment variable
~ %USERPROFILE% $env:USERPROFILE
variable=value %variable%=value $variable=value
cp source target copy source target  
cp -r source target 
xcopy source target /e/h
find -name '*.txt
dir /s *.txt
grep text
findstr text
ls -a dir /a
rm file del file
rm -rf directory rmdir /s /q directory
which command
where command             (gcm command).Path

14 September 2025

Windows powershell Get-Process: get parentprocess ID / name, get process using port...

Powershell command to get parent processes of all processes with a given name (e. g. javaw.exe):

Get-CimInstance Win32_Process -Filter "Name = 'javaw.exe'" | select ParentProcessId

Or in a script. This one takes the process name as a parameter and also shows the , this time with the parent process name: 

$targetProcessName = $args[0]

$targetProcessName = $args[0]
$targetProcesses = Get-CimInstance -ClassName Win32_Process -Filter "Name = '$targetProcessName'"

foreach ($process in $targetProcesses) {
    $parentProcessId = $process.ParentProcessId
    $parentProcess = Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = $parentProcessId"
    Write-Output "Process: $($process.processId) $($process.Name), Parent Process: $($ParentProcessId)    $($parentProcess.Name)"
}

Powershell command to get ID of process occupying a port (e.g. 8080)

 Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess

 Once you have the id you can shoot it using 

taskkill /PID <processid> /F

 

5 February 2023

Printing an ID card photo in windows

 When printing a photo in windows, these are the options you get:

For the bigger formats you get the actual sizes, but for the smaller you get descriptions, which are unclear.

These are the actual sizes when printing:

  • wallet/portemonnee: 6 x 8 cm
  • overview/overzichtsafdruk: 2.5 x 3.8 cm

I'm keeping the sizes here because I always get it wrong. Wallet is way too large for an ID card photo, overview is a lot closer (although a tad too small)

21 May 2021

Windows: software to add (updated)

Current list of software I'm running:

19 September 2020

Windows: which java version do I use?

 On windows oracle java uses quite a complicated way to find the java executable.

> echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;...

Starting from javapath it uses quite a complex mechanism, which well explained in this stackoverflow answer.

Ultimately the windows registry is used, like I also explained earlier.

When you frequently have to hop from one Java version to another, it is a good idea to store the path to your java binaries in the JAVA_HOME environment variable and prepend that to your windows path.

12 February 2020

git on Windows: HTTP basic authentication failed

I had been playing a bit with git security: SSH authentication, GPG signing, different user accounts and the like. A little later I reverted back to HTTPS, but now my gitlab push failed with
HTTP basic authentication failed.
No matter which git config i changed, I could not get this going.
Problem is that credentials were cached in the windows credential manager.
Hard to find an interface to that program. The command you have to run to get access is

> rundll32.exe keymgr.dll, KRShowKeyMgr
This gives you a window with a list of cached credentials. I Removed the gitlab entry and lo! next time I push I get a nice popup requesting my username/password. Next push, everything works without the popup, means Windows credential manager caches the right stuff from now on.

3 May 2018

windows 10 logon/logoff tracking by filtering system events

When I'm late filling in my timesheets, it always is a headache to remember which hours I spent working. My windows event viewer (eventvwr.msc) can be a help but the logs are too crowded.
The events related to logon/logoff are polluted with plenty of events from system services.
So I ventured to create a filter only showing the events relating to my user. This requires XML filtering based on XPATH.

  1.  Create a new custom event view
    1.  right click the security category and select Create Custom View...
    2.  enter the event ID's you want to filter. For logon/logoff these are 4624, 4634 and 4647
      1. You can get the id's by examining your events or from this MSDN page.
UPDATE: I'm often not logging off when I'm away, and this method does not log system sleep. Instead of monitoring logon/logoff I made a new filter that logs By source on event source Power-Troubleshooter. The details in the logs show the time the system went to sleep and woke up. The time in the details are in Zulu time (UTC+0), so they are some hours of from the real time, but given that the event time is correct, this is easy to deal with. The post remains interesting as a general explanation of event filtering, so I just added this update, and did not modify the general procedure
  1. Modify the base filter. 
    1. There is a field for filtering on the user name in the filter definition form, but that did not work. By clicking the XML tab we can edit the XML filter definition. Take care: you will not be able to edit the filter using the graphical user interface anymore after that.
    2. I added user filtering in the XML. This is my filter
    3. <QueryList>
        <Query Id="0" Path="Security">
          <Select Path="Security">
            *[System[( EventID=4624 or EventID=4634 or EventID=4647)] 
              and EventData[Data[@Name='TargetUsername']='jan']]
          </Select>
        </Query>
      </QueryList>
      
    4. I saved the filter and provided a name for the new custom filter. 
  2. We're done
Now you might wonder where I got the name of the field I needed to filter on from.  You can get the XML element names by examining the event in your logs
  1. In eventviewer, pick a logon event of logon type 2. More info on logon events...
  2. Select the event and in the bottom  half of the window you see the details
  3. Select the Details Tab, then the XML view button. This shows you the name/value pairs on which you can filter. I  want to filter on my user, so I'll need the SubjectUserName field.
On this Micorosoft technet page you find more info on XML event filtering.

10 December 2017

Google Drive File Stream: Drive letter changing on Windows (bug + workaround)

Google is replacing Google Drive with Google Drive File Stream (GDFS).
With GDFS you can (finally) cherry pick the folders that are synchronized to your local Drive (default: none).
GDFS mounts all network shares by default to drive G (what did you expect?).
Under G you will find a folder for your personal Drive and another folder for team drives you are member of (new with GDFS).
If the G drive is taken, GDFS takes the H drive and so on...

But...
Every once in a while GDFS mistakenly thinks the G drive is occupied and switches to H, next time it is back on G again... Very annoying if you have an absolute path reference to something on your drive (shortcuts, scripts...). The solution is a classic Windows trick: stop and restart:

  1. Go to your task bar tray, right click the GDFS icon and choose quit
  2. Start Drive File Stream again from the Start Menu.
Users are really annoyed by this bug, so let's hope it's fixed soon.

10 March 2016

SoapUI C:\WINDOWS\system32\config\systemprofile\soapui-settings.xml (Access is denied)

I installed SoapUI open source 5.2.1 on windows10 from the (default) windows 64 bit installer.

This installation considers C:\WINDOWS\system32\config\systemprofile as the home directory and insists on keeping his config there. Probably because it asks system administrators priviliges while installing and then derives the home directory from the system administor settings. When running SoapUI as your humble self afterwards and try to change any preferences you get

java.io.FileNotFoundException: C:\WINDOWS\system32\config\systemprofile\soapui-settings.xml (Access is denied)
 Uninstall and reinstall from the zip installer (from alternate platforms downloads). That one works from your user home directory as it should.

20 January 2016

windows 10: easy PATH editing

In windows 10 Microsoft has finally provided an update for the PATH setting mechanism that must have been around since the earliest versions of windows I remember (windows 3?).
In those versions you had a one line input box of about 30 characters for setting a path that could be hundreds of characters long. Now they have provided an easier tool, although it is harder to find :).
From the start menu, go to:

Settings > System > About > Advanced System Settings > Environment Variables

Alternatively, use the search in the task bar:


When editing the Path System variable, you get a list editor for the entries (instead of the semicolon separated list inherited from Unix). For editing an entry you have an optional directory browser.


9 August 2015

Windows 10 upgrade: login fails

After upgrading to windows 10 my password was not accepted !?
Issue: Windows had changed my default keyboard layout to US/Eng, which did not match my keyboard.
This is a setting you can change in the right bottom corner of the login screen, issue solved:


Some people also use their keyboard driver, the on-screen keyboard can help here:

22 February 2014

Microsoft cuts windows prices with 70% on cheap devices

Microsoft normally charges €50 for a pre-installed windows.
It has reduced this price to €15 for any device selling under €250, according to Bloomberg.
This is clearly a move to compete with tablets running Apple and Google software.

21 November 2010

Windows 7: Subsystem for Unix-based applications (SUA)

Yesterday I was trying to telnet from my new Windows 7 PC and... telnet was not there anymore. I had to go to "Control panel>Programs and Features>Turn Windows features on or off" to activate it.
While being in turn features on/off there was some other interesting stuff:

  • NFS client (!)
  • Subsystem for Unix-based applications
Subsystem for Unix-based applications (SUA) is the new name for Windows Services for UNIX (SFU),which in its turn is an evolution of the Interix system that Microsoft acquired. It is a set of utilities that make Windows POSIX compliant and eligible for tenders that require POSIX. Compliance is a very different goal then features and usability, so don't expect too much. The option is only present on Ultimate/Enterprise editions (Vista or later).

After rebooting  I could go to All Programs > Subsystem for Unix-based applications and... download utilities for Subsystem for Unix-based applications. That's right, it just enables the possibility to run POSIX programs, but Unix utilities themselves were not bundled, not even a shell.


Going to the download page you get these choices:
  1. Utilities and SDK for UNIX-based Applications_AMD64.exe
    • use for 64 bit Windows on Intel or AMD x86 processors
  2. Utilities and SDK for UNIX-based Applications_IA64.exe 
    • Use for Intel itanium
  3. Utilities and SDK for UNIX-based Applications_X86.exe
    •  use for 32bit Windows on Intel or AMD x86 processors
Take special care, to download the AMD64 file for Intel 64bit x86 architecture. Microsoft supposes unix heads know that AMD did not follow Intel on the 64bit Itanium path and made a 64 bit x86 (pentium) architecture version. Afterwards Intel followed the AMD strategy and started producing 64bit x86 processors as well.

When installing, choose custom installation if you want to include GNU stuff.  When installation is done, Windows prompts for another reboot.

Your system is by default installed with a root directory mapped to c:\Windows\SUA. You can now start a shell from the SUA menu. You can also run commands from windows by passing them as arguments  to c:\Windows\posix.exe. From a SUA shell you can access your windows drives from /dev/fs (e.g. /dev/fs/C is your C  drive).