当我运行此命令时
PS C:\> gwmi Win32_Process | select CommandLine
它切断了命令行。如何让它显示完整的命令行?
答案 0 :(得分:7)
由默认格式化完成,即使用format-table。尝试格式列表
gwmi win32_process | select commandline | format-list
答案 1 :(得分:2)
另外,Format-Table提供-wrap和-autosize参数。
gwmi win32_process | select handle, commandline | ft -wrap -autosize
结果
466 %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,768 Windows=On SubSystemType=Windows ServerDll=bas
esrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileContro
l=Off MaxRequestThreads=16
550 wininit.exe
510 %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,768 Windows=On SubSystemType=Windows ServerDll=bas
esrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileContro
l=Off MaxRequestThreads=16
546 C:\Windows\system32\services.exe
596 C:\Windows\system32\lsass.exe
3472 "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
1766 "C:\Windows\system32\notepad.exe"
3384 "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe"
1780 \??\C:\Windows\system32\conhost.exe
答案 2 :(得分:1)
最好通过PID或进程名称对特定进程进行过滤,如果您不知道的话,两条信息都可以从任务管理器中轻松获得。
一旦有了PID,这将非常有用:
$ PID = <您的进程ID)
(Get-WmiObject win32_process -Filter ProcessId = $ PID -Property CommandLine).CommandLine
通过进程名称获取java.exe的示例: (Get-WmiObject -win32_process类-Filter“ Name ='java.exe'” -Property CommandLine)。命令行
由barlop添加
输出示例-
PS C:\Users\User> (Get-WmiObject win32_process -Filter ProcessId=1676 -Property CommandLine).CommandLine <ENTER>
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --type=renderer --field-trial-handle=1108,1777349067310493
8616,10462310811264875730,131072 --lang=en-GB --enable-auto-reload --origin-trial-disabled-features=MeasureMemory --devi
ce-scale-factor=1 --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=1695 --no-v8-untrust
ed-code-mitigations --mojo-platform-channel-handle=11412 /prefetch:1
PS C:\Users\User>
答案 3 :(得分:0)
这是有关Powershell如何输出格式的常见问题。除了扩大窗口之外:
gwmi Win32_Process | % CommandLine
sihost.exe
C:\Windows\system32\svchost.exe -k UnistackSvcGroup
taskhostw.exe {222A245B-E637-4AE9-A93F-A59CA119A75E}