code_junkie

How to get command line arguments for a running process

Nov 11th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main(int argc, char* argv[])
  6. {
  7. ofstream cmdLine;
  8. cmdLine.open("cmdline.txt");
  9.  
  10. for (int i = 0; i < argc; i++) {
  11. cmdLine << argv[i];
  12. if (i < argc)
  13. cmdLine << " ";
  14. }
  15.  
  16. cmdLine.close();
  17. return 0;
  18. }
  19.  
  20. require 'win32ole'
  21. wmi = WIN32OLE.connect("winmgmts://")
  22. processes = wmi.ExecQuery("select * from win32_process")
  23.  
  24. for process in processes do
  25. cmdLine = process.CommandLine
  26. puts "Command line: #{cmdLine}" if cmdLine =~ /mxmlc/
  27. end
  28.  
  29. puts "Command line: #{cmdLine}" if cmdLine =~ /mxmlc/
Add Comment
Please, Sign In to add comment