Sign in to follow this  
Followers 0
ericli03

Remote Execution through WMI

6 posts in this topic

#1 ·  Posted (edited)

How to open a remote computer program through WMI.

I use WMI Win32_Process remote computer can successfully open Process,But failed to open a graphical interface that only shows running in the Process.

If the remote I run Notepad, how to open it? (Non-Process mode) Like manually open Notepad as open.

I am looking for some articles, some say that Windows permissions problem.

Code :

  $Username = ""
  $Password = ""
  $Computer = ""
Func RemoteExecute($strProgToRun)

    Local $objWMIService, $objProcess, $objProgram

    $objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
 

    $objWMI = $objSWbemLocator.ConnectServer($Computer, "rootcimv2", $Username, $Password)  
 
    $objWMI.Security_.ImpersonationLevel = 3

    $objProcess = $objWMI.Get("Win32_Process")

    $objProgram = $objProcess.Methods_("Create").InParameters.SpawnInstance_
    $objProgram.CommandLine = $strProgToRun

    $objWMI.ExecMethod("Win32_Process", "Create", $objProgram)                                       

EndFunc

Can be performed, but only in Process mode, can not see graphic.

Another psexec can start properly, no problem.

Edited by ericli03

Share this post


Link to post
Share on other sites



you can not. this is a security consideration, and a very valid one. remote user - whoever he is, admin or not - should not be allowed to open a process running under the currently logged-on user security context. when you do a remote call, by PsExec or otherwise, it is run under the remote caller context. you are asking for code to run as if the logged-on user called it.

there are methods to override this, but the short answer is - you don't.

think what you are trying to accomplish, i'm sure you'll find a much more valid and simple way to do it. you can present your goal here, if it is legitimate you will get all the help you can get.

Share this post


Link to post
Share on other sites
Thank orbs!
 
I wish there could open the remote computer as a way exe file in addition psexec outside ..
 
Tried some methods (WMI, TCP), but it seems there is only Psexec way.
 
There are other ways to remotely turn it? 

Share this post


Link to post
Share on other sites

What is the application you're trying to execute remotely, and why would you want to do so in the remote user's context rather than just instructing the user to launch it themselves?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

If you have the luxury of being able to have your script on the remote PC, you can use TCP to do your work. Check out TCPSend() and TCPRecv() in the helpfile, there are great examples in there of how to use them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0