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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a non hidden, remote process?

Status
Not open for further replies.

thomasmcgeown

Technical User
Feb 6, 2002
27
GB
Hi,

Im trying to create a process on a remote computer, however i dont want the process to be hidden, i.e if the process is notpad.exe then i want a notepad to open on the remote computer.

However my current code just runs the process and does not show the window.

MINIMIZED_WINDOW is a constant with a value of 1
strings are self explanitory.

======================================

Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = MINIMIZED_WINDOW
errReturn = objProcess.Create(strProcessName, strProcessPath, objConfig, intProcessID)

======================================

any suggestions?
 
for anyone who was interested.. seems this is impossible using the WIN32_Process class, its made non interactive for security reasons apparently, guess it makes some sort of sence.

gonna try and do it by creating a scheduled task with a small amount of time added to the system time.
 
thank you for your help vanvb, id like to do this myself tho, a combination of being to proud to admit defeat and knowing that a decent challange will improve my abilities more than taking an easier route!

Thanks again for your suggestion!

Tom
 
Thomas,
How are you making out on this? I took some more interest as I can think of a need for this myself and I understand not wanting to shell out to another .exe, so I have looked around for a bit trying to find a solution for this and I think that based on your question, I am about where you are. I am executing the process remotely, but it always just shows up as a process in the task manager...that's all it does. This does work when I have the machine name set as the local machine as below. Here is what I have:

Code:
Dim strCPUName As String
Const NORMAL_WINDOW = 5
On Error Resume Next

strCPUName = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strCPUName & "\root\cimv2")
Set objStartup = objWMIService.Get("WIN32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = NORMAL_WINDOW
Set Process = GetObject("winmgmts:\\" & strCPUName & "\root\cimv2:Win32_Process")
result = Process.Create("notepad", Null, objConfig, ProcessID)
Debug.Print "Method returned result = " & result
Debug.Print "Id of new process is " & ProcessID
Note: Add a reference to Windows Script Host Object Model

This should work as I have it written out, but it doesn't. The only thing I have found is one refernce on Microsoft's site that says that the Create method used above can't create a. interactive process on a remote machine due to security restrictions. That in mind however, other sources say that it should work. Any thoughts on your or anyone else's mind?

Let me know...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top