汪汪汪~ 关于命令行获取,大家帮帮忙。。

ArLi2003 2003-08-15 12:55:59
问题粉简单:

获取指定(或所有当前运行中)进程的完整命令行,特别是参数
(就象sysinternals 的 Process Explorer)

试过getstartupinfo/getcommmlinea 都没法,是不是必须要hook 切入DLL然后再getcommandline ?
...全文
49 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
ArLi2003 2003-08-18
  • 打赏
  • 举报
回复
谢谢思归了 ;-) 结帐
CMIC 2003-08-16
  • 打赏
  • 举报
回复
gz
saucer 2003-08-16
  • 打赏
  • 举报
回复
This sample demonstrates how to get the command line another process was started with:
http://mvps.org/win32/processes/remthread.html
saucer 2003-08-16
  • 打赏
  • 举报
回复
http://www.csdn.net/Develop/Article/18/18722.shtm
saucer 2003-08-16
  • 打赏
  • 举报
回复
see

http://fravia.anticrack.de/natz_mp2.htm
ArLi2003 2003-08-16
  • 打赏
  • 举报
回复
3q saucer,但是你的地址里面最重要的

"See http://www.codepile.com/tric14.shtml for details"

i can'n open... ;-(
ArLi2003 2003-08-16
  • 打赏
  • 举报
回复
谢谢 saucer,想不到读个命令行参数要这么累呀。。。晕

你给的 http://mvps.org/win32/processes/remthread.html 我已经下载,但是有个问题就是它的CreateRemoteThread 据我所知在win9x 是不受支持的。。另外,这个unsafe getcommandline 植入到目标进程中去run 是不是会有局限性,比如某些安全性比较强的程序可能会拒绝(没试过)这种入侵?

谢谢大虾,这个是可以用的,比我的WMI 还多支持了win2k。

还有没有简单一些的(可以不从commandline 入手,只要求获取该程序启动时的参数就行了),win32 真的没有获取参数支持?那wmi 怎么搞的到commandline 哩。。

如果没有就结帐,3q all ;-)
saucer 2003-08-15
  • 打赏
  • 举报
回复
you probably have to work with unsafe code, see this guy's suggestion:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=F07Z5.83483%24lR2.2679507%40afrodite.telenet-ops.be
ArLi2003 2003-08-15
  • 打赏
  • 举报
回复
最后的版本:
http://zpcity.com/arli/commonprj/cls_GetCommandLineEx.cs

可是还是没法用API 做到,WMI 做总是不好多个服务依存而且还必须是xp 以上,里面的CommandLine_API 哪位帮忙写一下!

急用。。。
chainet 2003-08-15
  • 打赏
  • 举报
回复
下面这篇文章是讲怎么从命令行获得标准输入输出的,是C++的,但也许对你有帮助。
http://contextfree.net/wangyg/tech/myIDE.htm
ArLi2003 2003-08-15
  • 打赏
  • 举报
回复
翻烂了WMI 也没找到更好的,而且根据 sysinternals 的 Process Explorer 的函数引用分析它使用的肯定不是wmi 而最有嫌疑的就是 getcommandline,可偶就是搞不出来,难道sysinternals 知道它有隐藏参数

;-(
ArLi2003 2003-08-15
  • 打赏
  • 举报
回复
搞了半天终于找到一个可用的:

using System;
using System.Management;

namespace ArLi.CommonPrj {
public class GetCommandLineEx {

public static readonly System.Version myVersion = new System.Version(1,1);

/// <summary>
/// LocalHost
/// </summary>
public static string CommandLine_WMI(){
System.Management.ManagementScope ms = new System.Management.ManagementScope(@"\\.\root\cimv2");
System.Management.ObjectQuery oq = new System.Management.ObjectQuery("select * from win32_process");
ManagementObjectSearcher query = new ManagementObjectSearcher(ms,oq);

ManagementObjectCollection moc = query.Get();

string s = "";

foreach(ManagementObject mo in moc) {
s += (string)mo["CommandLine"] + "\r\n";
}
return s;
}
}
}

但是这个

CommandLine
Data type: string
Access type: Read-only

Command line used to start a specific process, if applicable. This property is new for Windows XP.

这下可惨了,我的程序要求有win98 哩。。。最少也要win2k 能跑呀,为为,大家一起帮帮忙想想啊
ekeen 2003-08-15
  • 打赏
  • 举报
回复
up
jlhdlj 2003-08-15
  • 打赏
  • 举报
回复
up
ArLi2003 2003-08-15
  • 打赏
  • 举报
回复
cc 公主说的我早试过了

public static string RunningInstance() {
Process[] processes = Process.GetProcesses();
string s = null;

foreach (Process p in processes) {
s += p.WorkingSet + p.ProcessName + "\r\n" + p.StartInfo.FileName + " " + p.StartInfo.Arguments;
}

return s;
}

结果是p.StartInfo 里都是空值,因为StartInfo 是要传递的属性而不是用来获取已存在进程的属性
维她奶 2003-08-15
  • 打赏
  • 举报
回复
up
nyucv 2003-08-15
  • 打赏
  • 举报
回复
GZ
ruanyuping 2003-08-15
  • 打赏
  • 举报
回复
gz
xixigongzhu 2003-08-15
  • 打赏
  • 举报
回复
Environment只对当前进程有用,如果是别的进程,用:
String cmd = process.StartInfo.FileName + " " + process.StartInfo.Arguments;
colin666 2003-08-15
  • 打赏
  • 举报
回复
gz
加载更多回复(3)

110,570

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧