我使用PowerShell运行以下代码,以从注册表中获取添加/删除程序的列表:
Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
| ForEach-Object -Process { Write-Output $_.GetValue("DisplayName") } `
| Out-File addrem.txt
Run Code Online (Sandbox Code Playgroud)
我希望列表按每个程序的换行符分隔.我试过了:
Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
| ForEach-Object -Process { Write-Output $_.GetValue("DisplayName") `n } `
| out-file test.txt
Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
| ForEach-Object {$_.GetValue("DisplayName") } `
| Write-Host -Separator `n
Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
| ForEach-Object -Process { $_.GetValue("DisplayName") } `
| foreach($_) { echo $_ `n }
Run Code Online (Sandbox Code Playgroud)
但是当输出到控制台时,所有这些都导致奇怪的格式化,并且当输出到文件时,每行后面都有三个方格字符.我想Format-List,Format-Table和Format-Wide没有运气.最初,我认为这样的事情会起作用:
Get-ChildItem -path hklm:\software\microsoft\windows\currentversion\uninstall `
| ForEach-Object -Process { "$_.GetValue("DisplayName") …Run Code Online (Sandbox Code Playgroud) 使用ShellExecute文档作为参考:
我从命令行运行以下命令:
C:\>RUNDLL32.EXE SHELL32.DLL,ShellExecute handle,"open","C:\Documents and Settings\admin\Desktop\tmp",NULL,NULL,SW_SHOWNORMAL
Run Code Online (Sandbox Code Playgroud)
这会导致异常错误.
我不知道这意味着什么:
HINSTANCE ShellExecute(
__in_opt HWND hwnd,
__in_opt LPCTSTR lpOperation,
__in LPCTSTR lpFile,
__in_opt LPCTSTR lpParameters,
__in_opt LPCTSTR lpDirectory,
__in INT nShowCmd
);
Run Code Online (Sandbox Code Playgroud)
但是在描述中,提到了句柄(HWND)和指向以空字符结尾的字符串(LPCTSTR)的指针,但它非常混乱.
任何帮助将不胜感激.我还想了解更多,所以任何参考(书籍,网络链接等)也会很棒!