簡體   English   中英

是否可以從 Cygwin ssh session 正確執行 qwinsta?

[英]Is it possible to properly execute qwinsta from a Cygwin ssh session?

我在 Windows 7 機器上運行 Cygwin,並在其上運行 Cygwin ssh 服務器。 在 Linux 我有一個 shell 腳本我想做

ssh myuser@mymachine "qwinsta | grep Active"

查看誰已登錄。這適用於 Windows Server 2008 R2 機器,但似乎在 Windows 7 上有問題。

如果我在 Windows 7 機器上嘗試這個,我會得到:

bash: qwinsta: command not found

現在,這就是奇怪的開始......

如果我正常登錄 Windows 7 機器並使用 Windows Explorer 查看 C:\Windows\System32,我看到了 qwinsta.exe。 如果我打開 CMD session 並在 C:\Windows\System32 中執行dir ,我會看到 qwinsta.exe。 如果我打開 Cygwin shell 並在 /cygdrive/c/Windows/System32 中執行ls qwinsta.exe ,我會得到:

ls: cannot access qwinsta.exe: No such file or directory

如果我從 Cygwin shell 執行cmd /c dir C:\\\\Windows\\\\System32\\\\qwinsta.exe ,我得到“文件未找到”

如果我將 qwinsta.exe 復制到我的 Cygwin 主目錄中,那么它在我的主目錄中使用 ls 可見。 如果我嘗試從 Cygwin shell 運行 qwinsta 的本地副本,它會運行,但它也會輸出一行:

{Message(): LoadString failed, Error 15105, (0x00003B01)}

Windows 7 上的 qwinsta 怎么了?

問題是qwinsta.exe實際上並不位於C:\Windows\System32中。 它實際上是在

C:\Windows\winsxs\amd64_microsoft-windows-t..commandlinetoolsmqq_31bf3856ad364e35_6.XX.XXX.XXXX_none_XXXXXXXX\qwinsta.exe

使用上述路徑(或相同的軟鏈接)將運行qwinsta.exe ,因為它存在於任何機器上,並且不需要您將可執行文件復制到您的主目錄。

錯誤消息{Message(): LoadString failed, Error 15105, (0x00003B01)}是關於多語言用戶界面(本地化)系統無法找到正在運行的程序的錯誤消息本地化信息(請參閱系統錯誤代碼)。 在這種情況下,cygwin shell 似乎沒有為qwinsta.exe提供在您的語言的語言環境文件夾中查找qwinsta.exe.mui所需的信息(通常是C:\Windows\System32\en-US或任何您的語言環境成為)。 查看此文件夾有些誤導,因為資源管理器將顯示此目錄中的文件,但是當您運行ls /cygdrive/c/Windows/System32/en-US時,沒有qwinsta.exe.mui文件。 我懷疑這與 NTFS 中的新鏈接結構有關(請參閱mklink命令),但我還沒有弄清楚如何解決這部分問題。

解決了:

  1. First, go to C:\Windows\winsxs\amd64_microsoft-windows-t..commandlinetoolsmqq_31bf3856ad364e35_6.1.7600.16385_none_851e6308c5b62529 (Copy and pasting that location works just as well as manually finding it.) You should find three files: Msg.exe , Quser.exeqwinsta.exe 將這些文件復制到C:\Windows\system32文件夾

  2. Next, go to C:\Windows\winsxs\amd64_microsoft-windows-t..etoolsmqq.resources_31bf3856ad364e35_6.1.7600.16385_en-us_7bef78d9f4a6a8ac

您應該找到三個名稱相似的文件,除了這些文件將以.mui

  1. 將所有這三個文件復制到C:\Windows\system32\en-US文件夾。

  2. 現在嘗試運行msg程序。 它應該可以正常工作。

Windows 10

Erutan2099 的回答之后,對於 Windows 10 來說,這有點棘手,因為文件被壓縮(二進制增量壓縮,文件簽名44 43 53 01 )。 嘗試按原樣使用它們會引發Unsupported 16-Bit Application錯誤:

由於與 64 位版本的 Windows 不兼容,程序或功能“\??\C:\Windows\System32\msg.exe”無法啟動或運行。 請聯系軟件供應商詢問是否有 64 位 Windows 兼容版本可用。

已經制作了一個特定的工具來解壓這些文件: SXSEXP這篇文章為我指明了正確的方向)


用法:

> sxsexp64.exe msg.exe expand\msg.exe
Processing target path  msg.exe
msg.exe => expand\msg.exe
File size               12602 bytes

DCS_HEADER found.

 NumberOfBlocks         1
 UncompressedFileSize   26112

DCS_BLOCK #1
 Block->CompressedBlockSize     0000312A
 Block->DecompressedBlockSize   00006600
Operation Successful
> sxsexp64.exe msg.exe.mui expand\msg.exe.mui
Processing target path  msg.exe.mui
msg.exe.mui => expand\msg.exe.mui
File size               2150 bytes

DCS_HEADER found.

 NumberOfBlocks         1
 UncompressedFileSize   7680

DCS_BLOCK #1
 Block->CompressedBlockSize     00000856
 Block->DecompressedBlockSize   00001E00
Operation Successful

這些解壓文件現在可以分別復制到C:\Windows\System32C:\Windows\System32\en-US

例子:

> msg * Hello, World!

消息框

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM