Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What Scripts Are Running on My Computer?

Status
Not open for further replies.

Sasquatch69

Programmer
Sep 20, 2002
19
CA
I need to know what Script are Running on my computer. On Windows XP, i can use this little script:

Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile("c:\test.log", 8 , True)

'Get parameters (Process ID)
Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count - 1
ID = objArgs(I)
Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Select process with parameter ID.
Set colProcesses = objWMIService.ExecQuery( "select * from win32_process where ProcessId = " & ID )

For Each objProcess in colProcesses
' Wscript.Echo "Process " & objProcess.CommandLine & " Process Id " & objProcess.ProcessId
' Écriture dans fichier de sortie
f.writeLine " Process Id: " & objProcess.ProcessId
f.writeline " jobs : " & objProcess.CommandLine
f.writeLine " Date : " & Now()
f.WriteLine "********************************************"
f.WriteLine " "
Next

'Close file.
f.close


But it's does'nt work with windows 2000, "objProcess.CommandLine" is not supported in windows 2000!! Anyone can help me.

Thanks, and sorry for my bad english.
 
Hello Sasquatch69,

Use instead .executablepath:
f.writeline " jobs : " & objProcess.ExecutablePath

regards - tsuji
 
The result is not the same as "CommandLine". If i use CommandLine, i receive the name of the batch file i use to start my vbs.
objProcess.CommandeLine return:
cmd /c ""C:\testcall.bat" "

testcall.bat is the program who call the VBS file.

If i use Executable path, i only receive the program(and not the name of the program) executable.

objProcess.ExecutablePath return:
C:\WINDOWS\System32\cmd.exe


Thanks tsuji.

this program return the same information on windows 2000 and XP. It's certainly wrote in C++ but i hope i can have the same result on WINDOWS 2000 with vbscript.(vbs work on XP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top