Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Windows

Windowsで他のユーザで管理者権限でコマンドを実行

背景 Stack Overflowに質問を投稿するため、コマンドの出力やスクリーンショットを英語のWindows環境で取得したい。 コマンドの出力やスクリーンショットをとるために、ロケールを英語にしたユーザを用意している。 普段使いのユーザアカウントのロケールは…

WindowsでWireSharkを使わずパケットをキャプチャする方法の比較

satob.hatenablog.com 実際にWindows 11上で確認した結果をまとめた。 # 確認方法 通信 キャプチャコマンド プロトコル ファイルサイズ 確認可否 備考 1 Microsoft Message Analyzer curl.exe netsh trace HTTP 2621440 OK 不要なデータが多いためフィルタで…

Windows標準搭載のフォントで長いURLの表示に適したもの

デフォルトフォント 游ゴシック 日本語入り等幅フォント BIZ UDゴシック MSゴシック 英文等幅フォント lConsolas Courier Courier New Lucida Console 英文プロポーショナルフォント Bahnschrift Light Condensed 固定幅でないことに目を瞑れば、Bahnschrift…

Npcap alternatives for Windows environment

Npcapのライセンスはちょっとややこしくて、無償版のライセンスは5システムまで使用可能、またNmap, Wireshark, Microsoft Defender for Identityで使う場合は何ライセンスでも利用可能となっている*1*2。使っているソフトウェアのライセンスをUEM製品で管理…

Use Invoke-CommandInDesktopPackage as countermeasure of "failed to run: Access is denied"

Problem When you launch in some .exe in C:\Program Files\WindowsApps, sometimes you will get the error message like this: Program 'wsl.exe' failed to run: Access is denied At line:1 char:1 This error will happen even if you have launched a…

Get all available event IDs for each source on Windows Event Log

(Get-WinEvent -ListLog * -ErrorAction SilentlyContinue).ProviderNames | Sort-Object -Unique | ForEach-Object { $SourceName = $_; try { (Get-WinEvent -ListProvider $SourceName -ErrorAction SilentlyContinue).Events | ForEach-Object { $Event …

Windows Nano ServerコンテナでPostgreSQLのインストーラが実行できない

EnterpriseDBが配布しているWindows用のPostgreSQLインストーラにはサイレントインストール用のオプションが指定できて、各オプションの詳細は以下で説明されている。 silentinstallhq.com コンテナへのインストールなのでサイレントインストールにすればOK…

Windowsコンテナを対話型セッションで起動しようとすると80070002エラーが発生する

PS C:\docker> docker run mcr.microsoft.com/windows/nanoserver:ltsc2022 -it cmd.exe docker: Error response from daemon: container 23562ad343abb674269577807f3915b8e596bb557b9623f62a32b8920f685889 encountered an error during hcs::System::Crea…

WindowsのWSLでSSHのpemファイルをchmod 400できない

問題 WindowsからWSLのSSHで公開鍵(.pem)を使ってログインしようとした際、pemファイルのパーミッションがowner以外から読み出し可能になっていると、OpenSSHが以下のようなエラーメッセージを出して接続に失敗する。 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@…

コンボボックスとかドロップダウンリストとかプルダウンリストとか

コンボボックスとかドロップダウンリストとかプルダウンリストとか言われるものが何を指しているか、ドキュメントごとに違うように見えるので調べてみた。 ドロップダウンリストの例 Windows User Experience Interaction Guidelines *1 "standard list box"…

Way to shutdown Windows

There are so many ways to shutdown Windows: # How to shutdown What is executed Wait for HungAppTimeout 1 shutdown from Start Menu RuntimeBroker.exe Yes 2 shutdown from the lock screen winlogon.exe No 3 execute SlideToShutDown.exe SlideToSh…

Windowsをシャットダウンする方法いろいろ

Windowsをシャットダウンする方法には スタートメニューから「シャットダウン」を選択(内部的にはC:\Windows\System32\RuntimeBroker.exeが呼ばれているみたい) デスクトップでAlt+F4を押して「シャットダウン」を選択 ロック画面から「シャットダウン」を…

間欠動作するアプリケーションむけActive Directoryアクセストークンの保存方法の検討

OutlookやSharePointのAPI、バックグラウンドのアプリケーションで使おうとするとすぐ管理者の同意が必要なPermissionを求めてくる。 たとえばバックグラウンドアプリから自分のOneDriveへファイルをアップロードしたい場合、Azure Active DirectoryでFiles.…

EdgeのIEモードはIEなのか?

Windows 11 Pro 21H2 (22000.282)で確認。 Microsoftは何と言っているか? 「従来のサイトには、Internet Explorer 11 (IE11) から Trident MSHTML エンジンを使用します」と言っている*1。IEモードはIE 11であると言える。 WindowsからIE 11をアンインスト…

Record the mouse position and the top window title to Windows Event Log

Requirement Record the user activity to Windows Event Logs. The mouse position*1 and top window title *2 are used to indicate the activity. Solution Run the following PowerShell script every 5 minutes from the Task Scheduler. Add-Type -Ass…

Record a Windows Event Log with a custom application/source and appropriate message

Requirement You want to record an event on Windows Event Log. The log should be recorded with a custom application and source. The message of the event should be recorded appropriately. The message should not contain the warning like The d…

You cannot show fullscreen message and log-off after a time-out with shutdown.exe

Background You can log off from Windows with shutdown.exe. Requirement You want to log off from Windows at the specified time. It should not be shut down after the log-off. You want to show a fullscreen message 5 minutes before the log-off…

Windows Event Viewer Category Correspondence Table

I couldn't find the correspondence table between the value of the -Category argument (Int16) of Write-EventLog cmdlet and the category shown in Event Viewer from Microsoft. I have run this command and viewed the result in the Event Viewer …

OneDriveをリポジトリとしてファイルのバージョン管理を行う方法の案

個人的な作業の成果物の管理用に、ローカルストレージやファイル共有にバージョン管理システムのリポジトリを作っていたが、それをOneDriveに移さないといけない……というケースに対する予備調査。「Subversion」は任意のバージョン管理ソフトウェアの名前に…

ウィンドウ右下のサイズ変更用エリアの名前

Windowsのメモ帳のステータスバー右下なんかに表示されてるコレの名前、ドキュメントによって呼び名が違う。 MFCのAPIリファレンスだと "gripper" と呼ばれている。Prof-UISでもgripperと呼んでいる。 .NETのAPIリファレンスだと "sizing grip" と呼ばれてい…

外部プロセスとしてシェルスクリプトを起動する方法

任意の処理系から外部プロセスとしてシェルスクリプトを起動したい場合、大きく以下の2つの方法が考えられます。 (1) shの引数にシェルスクリプトを指定する /bin/sh foobar.sh のように、shの引数にシェルスクリプトを指定して起動する。 shに与えるパラメ…

Overwriting existing file never change creation time in NTFS

Overwriting existing file like 1..10 > file.txt, 1..10 | Out-File file.txt, or 1..10 | Set-Content file.txt, never changes creation time in NTFS. You have to delete the file explicitly like rm file.txt; 1..10 > file.txt, or change creation…

TFTPでファイルのリクエストがタイムアウトになる

背景 デバイスのブート時にイメージをTFTPで流しこみたい。 TFTPで通信する際、デバイスのIPアドレスは192.168.11.1、TFTPサーバは192.168.11.168で固定になっている。 TFTPサーバにはWindows 10上のPumpKINを使っている。 PumpKINの設定で、リクエスト・レ…

Microsoft Print to PDFで出力したPDFファイルが0バイトになる問題を回避する

大きなPDFファイルを複数に分割しようと思って、Adobe ReaderからMicrosoft Print to PDFへ印刷してみたんだけど、できあがるPDFファイルが0バイトで、正常に出力されない。 Wordでも同じ現象が起こったので、これはMicrosoft Print to PDFの問題かな?と思…

cmd.exeとPowerShellの起動速度

体感ではPowerShellの起動速度はcmd.exeと比べて明らかに遅いけれど、具体的にどの程度遅いのか確かめてみた。 OSはWindows 10 version 2004、CPUはIntel(R) Core(TM) i7-8750H CPU @ 2.20GHz(6コア12スレッド)です。 なお、処理に使うウィンドウはPowerSh…

VM上のUbuntuとWSL2上のUbuntuの違い

WSL2が入ったのでUbuntuを入れてみた。主にsystemdの不在に伴って、VM上のUbuntuとはいろいろと違いがある。常用のツールはWSL2で、systemdやら何やらシステム管理のお試しはVMWareでやるのがいいかな。 initはsystemdではなく、MSが作ったinitが使われる。s…

You cannot set CPU affinity of PostgreSQL instance started through pg_ctl with Start-Process and Process.ProcessorAffinity

Background: In Windows, you can set the CPU affinity of an user process with Start-Process PowerShell cmdlet and System.Diagnostics.Process.ProcessorAffinity property like this: $app = Start-Process -FilePath C:\Windows\System32\mspaint.ex…

robocopy finished with no error, with erroneous result on OneDrive for Business

Background: You are using OneDrive for Bueiness. You are trying to copy files to OneDrive with robocopy. Problem: robocopy had finished with no error (with ERRORLEVEL 0), but the the size of the files on OneDrive is 0byte. Cause: It seems …

Laggy network connection between host and guest with Hyper-V on Windows 10

Problem When using Hyper-v on Windows 10, network connection between host and guest stops intermittingly. You can ping from host to guest. Ping causes "Request timed out" intermittingly. Ping losses around 10% of packets. Symptom doesn't c…

FNTCACHE.DATを削除できない場合の対処法

フォントがおかしくなったら、セーフモードで起動してC:\Windows\System32\FNTCACHE.DATを削除しろとMSのKBにもあるが、残念ながらシンクライアントであるわが社の端末でセーフモードに入るには大阪のデータセンターまで行かなくてはならないのだ! 通常起動…