Advertisement
Guest User

Untitled

a guest
Jul 20th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. /*
  2. - Create index.js with contents below
  3. - npm install --save edge
  4. - launch notepad.exe
  5. - run node index.js
  6.  
  7. output:
  8. [ben@oc2077774057 processtest]$ cat output.txt
  9. c:\vagrant\processtest>node index.js
  10. { HasExited: false,
  11. Id: 4052,
  12. Threads:
  13. [ { BasePriority: 8,
  14. CurrentPriority: 10,
  15. Id: 4392,
  16. PriorityBoostEnabled: true,
  17. PriorityLevel: 'Normal',
  18. PrivilegedProcessorTime: [Object],
  19. StartAddress: '140732887113520',
  20. StartTime: Wed Jul 20 2016 13:15:24 GMT-0700 (Pacific Daylight Time),
  21. ThreadState: 'Wait',
  22. TotalProcessorTime: [Object],
  23. UserProcessorTime: [Object],
  24. WaitReason: 'UserRequest',
  25. Site: null,
  26. Container: null },
  27. { BasePriority: 8,
  28. CurrentPriority: 8,
  29. Id: 3204,
  30. PriorityBoostEnabled: true,
  31. PriorityLevel: 'Normal',
  32. PrivilegedProcessorTime: [Object],
  33. StartAddress: '140732887113520',
  34. StartTime: Wed Jul 20 2016 13:35:55 GMT-0700 (Pacific Daylight Time),
  35. ThreadState: 'Wait',
  36. TotalProcessorTime: [Object],
  37. UserProcessorTime: [Object],
  38. WaitReason: 'EventPairLow',
  39. Site: null,
  40. Container: null } ],
  41. ProcessName: 'notepad',
  42. StartInfo:
  43. { Verb: '',
  44. Arguments: '',
  45. CreateNoWindow: false,
  46. EnvironmentVariables:
  47. [ [Object],
  48. [Object],
  49. [Object],
  50. [Object],
  51. [Object],
  52. [Object],
  53. [Object],
  54. [Object],
  55. [Object],
  56. [Object],
  57. [Object],
  58. [Object],
  59. [Object],
  60. [Object],
  61. [Object],
  62. [Object],
  63. [Object],
  64. [Object],
  65. [Object],
  66. [Object],
  67. [Object],
  68. [Object],
  69. [Object],
  70. [Object],
  71. [Object],
  72. [Object],
  73. [Object],
  74. [Object],
  75. [Object],
  76. [Object],
  77. [Object],
  78. [Object],
  79. [Object],
  80. [Object],
  81. [Object],
  82. [Object],
  83. [Object],
  84. [Object],
  85. [Object],
  86. [Object],
  87. [Object] ],
  88. Environment:
  89. [ [Object],
  90. [Object],
  91. [Object],
  92. [Object],
  93. [Object],
  94. [Object],
  95. [Object],
  96. [Object],
  97. [Object],
  98. [Object],
  99. [Object],
  100. [Object],
  101. [Object],
  102. [Object],
  103. [Object],
  104. [Object],
  105. [Object],
  106. [Object],
  107. [Object],
  108. [Object],
  109. [Object],
  110. [Object],
  111. [Object],
  112. [Object],
  113. [Object],
  114. [Object],
  115. [Object],
  116. [Object],
  117. [Object],
  118. [Object],
  119. [Object],
  120. [Object],
  121. [Object],
  122. [Object],
  123. [Object],
  124. [Object],
  125. [Object],
  126. [Object],
  127. [Object],
  128. [Object],
  129. [Object] ],
  130. RedirectStandardInput: false,
  131. RedirectStandardOutput: false,
  132. RedirectStandardError: false,
  133. StandardErrorEncoding: null,
  134. StandardOutputEncoding: null,
  135. UseShellExecute: true,
  136. Verbs: [],
  137. UserName: '',
  138. Password: null,
  139. PasswordInClearText: null,
  140. Domain: '',
  141. LoadUserProfile: false,
  142. FileName: '',
  143. WorkingDirectory: '',
  144. ErrorDialog: false,
  145. ErrorDialogParentHandle: '0',
  146. WindowStyle: 'Normal' },
  147. StartTime: Wed Jul 20 2016 13:15:24 GMT-0700 (Pacific Daylight Time) }
  148.  
  149. */
  150.  
  151.  
  152. /***** index.js: *****/
  153.  
  154. var edge = require("edge");
  155.  
  156. var get_process_state = edge.func(function () {/*
  157. using System.Threading.Tasks;
  158. using System.Diagnostics;
  159. using System.Dynamic;
  160.  
  161. public class Startup
  162. {
  163. public async Task<object> Invoke(dynamic input)
  164. {
  165. var processName = (string)input;
  166. var process = Process.GetProcessesByName(processName)[0];
  167. var pInfo = new {
  168. HasExited = process.HasExited,
  169. Id = process.Id,
  170. Threads = process.Threads,
  171. ProcessName = process.ProcessName,
  172. StartInfo = process.StartInfo,
  173. StartTime = process.StartTime
  174. };
  175. return pInfo;
  176. }
  177. }
  178. */});
  179.  
  180. var myProcess = get_process_state("notepad", true);
  181.  
  182. console.log(myProcess);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement