Get-FileHash
ショートカット(*.lnk)の扱いは、とりあえずDereferenceLinks = $trueとしておく。# PowerShell 5.1, Windows 11 (2024年9月頃)Set-StrictMode -Version Latest Add-Type -AssemblyName PresentationFramework $dlg=New-Object -TypeName...
View Article[Type.AssemblyQualifiedName]
下記の[Typeを入力するときに Ctrl + Spaceを押すと PublicKeyTokenまで補完される様子。テスト環境は PowerShell 5.1, Windows 11 (2024年9月頃)。[System.Runtime.InteropServices.RuntimeInformation...
View Articledotnet run
とりあえず dotnet runを試すPowerShell 5.1, Windows 11 (2024年9月頃), dotnet --version #=> 8.0.400$path=$env:USERPROFILE+"\Desktop\tmp"New-Item -ItemType Directory -Path$pathSet-Location -LiteralPath$path...
View Article音を鳴らす
Win32 API のwaveOutWriteで音を鳴らすVisual Studio 2022, Windows 11 (2024年9月頃)@rem Developer Command Prompt for VS 2022cd%USERPROFILE%\Desktop mkdir tmp cd tmp notepad test.c cl /utf-8 test.c /link Winmm.lib...
View ArticleXamlReader
Set-StrictMode -Version Latest Add-Type -AssemblyName PresentationFramework $xaml=@'<Window Title="テスト" Width="600" Height="300"...
View ArticlePowerShellでのOpenFileDialogがウイルス対策ソフトでブロックされる
Windows PowerShellでのMicrosoft.Win32.OpenFileDialog.ShowDialogとSystem.Windows.Forms.OpenFileDialog.ShowDialogがウイルス対策ソフトでブロックされる。# PowerShell 5.1, Windows 11 (2024年10月頃)Add-Type -AssemblyName...
View ArticleJPEGファイルのピクセル数を縦横半分にする
JPEGファイルのピクセル数を縦横半分にしたファイルを%USERPROFILE%\Desktop\tmpに作成画像の縮小にはTransformedBitmap(BitmapSource, ScaleTransform)を用いる# [テスト環境]# PowerShell 5.1, Windows 11 (2024年11月頃)# [スクリプトファイル(.ps1)]# <ファイル名>#...
View Article白黒画像ファイルを対象に画像の色を変更したい
ペイントで色を置換する作業が手間なので、効率化を考える。 Officeでの「色の変更」や「透明色を指定」は使用しない。. { # [テスト環境]# PowerShell 5.1, Windows 11 (2025年1月頃)# [スクリプトファイル(.ps1)]# <ファイル名># "testConvertColor.ps1"# <エンコード># UTF-8 (BOM付き)#...
View Articleリンク先の取得 FolderItem.GetLink.Path
ショートカット(.lnk)のリンク先を取得するとき、WshShortcut.TargetPathで取得できないことがあるのでShellLinkObject.Pathの使用を考える。ShellLinkObject# PowerShell 5.1, Windows 11...
View Article白黒画像ファイルの色を変更 Bitmap.Palette
ファイルサイズの関係で画像ファイルの「ビットの深さ」は1のまま運用したい。Graphics.FromImage, ImageAttributes,...
View Articleモノクロビットマップファイルの色を変更 BitmapSource.Palette
モノクロビットマップファイルのカラーパレットを変更した画像をPNGファイルとして保存する方法を考える。モノクロビットマップファイルはペイントでファイルの種類を「モノクロ ビットマップ」として保存したものを使用する。カラーパレットを指定するのでBitmapSource.FormatはPixelFormats.BlackWhiteではなくPixelFormats.Indexed1とする。. { #...
View ArticleUNCパス \\--1.ipv6-literal.net\c$
UNCパスを普通に\\--1.ipv6-literal.net\c$とはせず、無駄に文字数を増やすことを考える。\\--1%0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.ipv6-literal.net\c$\\[0000-0000-...
View ArticlePowerShell 5.1 で Windows.Data.Pdf.PdfDocument.PageCount を取得
型[Windows.Data.Pdf.PdfDocument]が見つかるかの確認# PowerShell 5.1, Windows 11 (2025年4月頃)$str='Windows.Data.Pdf.PdfDocument, Windows.Data, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null,...
View ArticlePowerShell 5.1 で Windows.Data.Pdf.PdfDocument.PageCount を取得 2
他人から入手したPDFファイルに対してPdfDocument.LoadFromStreamAsyncメソッドを試すと、うまく読み取れないPDFファイルが意外と多い。# PowerShell 5.1, Windows 11 (2025年5月頃)Set-StrictMode -Version Latest Add-Type -AssemblyName PresentationFramework...
View Article'ファイル名' -match '\p{C}'
外部から入手したファイルのファイル名にUnicode文字クラスエスケープの\p{C}や\p{M}に一致するものが含まれていて扱いに少し困った。文字列を確認するため PowerShell 5.1 にてTextElementEnumerator.MoveNext()を回して文字を確認する使い捨てスクリプトを作成した。確認する文字列が無い場合の例👨👩👧👦(()=>{const str0...
View Article