The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,806 other followers

Archive for the ‘Windows Development’ Category

How can you export the Visual Studio Code extension list? (via: Stack Overflow)

Posted by jpluimers on 2022/06/16

Adapted from [Archive.is] How can you export the Visual Studio Code extension list? – Stack Overflow, presuming that code is on the PATH:

  1. From the command-line interface on MacOS, Linux, BSD or on Windows with git installed:
    code --list-extensions | xargs -L 1 echo code --install-extension
  2. From the command-line interface on MacOS, Linux, BSD or on Windows without git installed:
    code --list-extensions | % { "code --install-extension $_" }

    or, as I think, more clearly (see also [WayBack] syntax – What does “%” (percent) do in PowerShell? – Stack Overflow):

    code --list-extensions | foreach { "code --install-extension $_" }

    or even more explanatory:

    code --list-extensions | ForEach-Object { "code --install-extension $_" }
  3. From the command-line interface on Windows as a plain cmd.exe command:
    @for /f %l in ('code --list-extensions') do @echo code --install-extension %l
  4. On Windows as a plain cmd.exe batch file (in a .bat/.cmd script):
    @for /f %%l in ('code --list-extensions') do @echo code --install-extension %%l
  5. The above two on Windows can also be done using PowerShell:
    PowerShell -Command "code --list-extensions | % { """""code --install-extension $_""""" }"

    Note that here too, the % can be expanded into foreach or ForEach-Object for clarity.

All of the above prepend “code --install-extension ” (note the trailing space) before each installed Visual Studio Code extension.

They all give you a list like this which you can execute on any machine having Visual Studio Code installed and its code on the PATH, and a working internet connection:

code --install-extension DavidAnson.vscode-markdownlint
code --install-extension ms-vscode.powershell
code --install-extension yzhang.markdown-all-in-onex

(This is about the minimum install for me to edit markdown documents and do useful things with PowerShell).

Of course you can pipe these to a text-file script to execute them later on.

The double-quote escaping is based on [Wayback/Archive.is] How to escape PowerShell double quotes from a .bat file – Stack Overflow:

you need to escape the " on the command line, inside a double quoted string. From my testing, the only thing that seems to work is quadruple double quotes """" inside the quoted parameter:

powershell.exe -command "echo '""""X""""'"

Via: [Archive.is] how to save your visual studio code extension list – Google Search

–jeroen

Posted in *nix, *nix-tools, .NET, bash, Batch-Files, CommandLine, Console (command prompt window), Development, Mac OS X / OS X / MacOS, Power User, PowerShell, PowerShell, Software Development, Visual Studio and tools, vscode Visual Studio Code, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Development, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, WSL Windows Subsystem for Linux, xargs | Leave a Comment »

On Windows, keep the lifetime of relative pathnames as short as possible because of thread-safety issues

Posted by jpluimers on 2022/05/18

Subtitle:

GetFullPathName thread-unsafety because of SetCurrentDirectory isn’t, so derived functions (like Delphi GetDir/ChDir/TPath.GetFullPath, or .NET System.IO.Path.GetFullPath) are not thread-safe either (via The Old New Thing)

A while ago I got a big reminder because of [Wayback] What are these dire multithreading consequences that the GetFullPathName documentation is trying to warn me about? | The Old New Thing:

Read the rest of this entry »

Posted in Delphi, Development, Pascal, Software Development, Turbo Pascal, Windows Development | Leave a Comment »

Windows applications: storing your data in the correct place (Roaming, Local, LocalLow, not Documents)

Posted by jpluimers on 2022/03/02

This is a follow on the below TomTom HOME complaint: Know where your application should store its data.

I know this can be tough, especially for applications that were developed before Windows Vista came around: that’s when CSIDL were introduced. But still: Windows XP already had %APPDATA% (the environment variable equivalent to CSIDL_APPDATA, it pointed to %USERPROFILE%\\Application Data)

Applications should store data under either of below locations. Values are KNOWNFOLDERID constants with CSIDL constants in parenthesis where available. Some have .NET equivalents in the System.Environment.SpecialFolder enumeration:

  • FOLDERID_LocalAppData (CSIDL_LOCAL_APPDATA)

    The file system directory that serves as a data repository for local (nonroaming) applications.

  • FOLDERID_LocalAppDataLow (n/a)

    The file system directory that serves as a data repository for local (nonroaming) applications that run under “low integrity” (like in a web browser).

  • FOLDERID_RoamingAppData (CSIDL_APPDATA)

     The file system directory that serves as a common repository for application-specific data.

Do not use FOLDERID_Documents (CSIDL_MYDOCUMENTS) as this is specific to user documents, not application data.

The virtual folder that represents the My Documents desktop item. This value is equivalent to CSIDL_PERSONAL.

Basically use FOLDERID_LocalAppData for data that is machine specific and FOLDERID_RoamingAppData for data that should travel to other machines when the user logs on to them.

Be very careful how much you store as potentially roamed data as these can go over slow networks (both low bandwidth and low latency).

Documentation

Read the rest of this entry »

Posted in .NET, Development, Software Development, Windows Development | Leave a Comment »

pipe – Windows how to redirect file parameter to stdout? (Windows equivalent of `/dev/stdout`) – Super User

Posted by jpluimers on 2022/02/02

TL;DR:

  • Windows has CON: which is an equivalent for /dev/tty
  • Windows has no equivalent for /dev/stdout (the standard output stream)
  • There is a C# PipeServer.cs proof-of-concept that allows to simulate /dev/stdout through a temporary named pipe
  • Windows pipe names start with \\.\pipe\ for names on the local machine
  • The above for /dev/stdout on Windows also holds for /dev/stdin (the standard input stream)

All via [Wayback] pipe – Windows how to redirect file parameter to stdout? (Windows equivalent of /dev/stdout) – Super User.

Read the rest of this entry »

Posted in .NET, C#, Development, Software Development, Windows Development | Leave a Comment »

Easiest way to move the C:\MSOCache directory to another drive is to create symbolic link to the new location

Posted by jpluimers on 2021/12/15

I always forget that, when moving a folder, instead of finding all references to that folder and fixing them, you can create an NTFS symlink from the old location to the new one.

[Wayback] how to move MSOCACHE folder from C-drive to D-drive ?? – Microsoft Community (thanks [Wayback] tgunda numbering and casing updates mine):

There are too much entries in the registry to correct them manually one by one.

An easier and quicker solution is to copy the full MSOCache folder to a new place and to make a soft link to it:
  1. Create a new folder, e.g. F:\MSOCache
  2. Copy everything from C:\MSOCache to the new one.
  3. Rename the old folder  C:\xMSOCache  (Don’t delete it, just in case).
  4. Open a command prompt window in administrator mode.
  5. Write:  mklink /d c:\MSOCache f:\MSOCache
Now there is an MSOCache link at C, pointing to the new place.
If everything is OK, you can delete  C:\xMSOCache

This can be very handy when moving around large software development installations, circumventing a full uninstall/install sequence loosing lots of configuration settings.

–jeroen

Posted in Development, LifeHacker, Office, Power User, Software Development, Windows, Windows Development | Leave a Comment »

 
%d bloggers like this: