 |
|
 |
More and more samples source code
|
|
|
|
 |
|
 |
When i`m run this code for my remote computer
with my admin settings: login,password and ip, and run code, then error
"HRESULT: 0x80070005 (E_ACCESSDENIED))" in ProcessMethod.cs
on this line №15:
ManagementBaseObject methodParams = processTask.GetMethodParameters("Create");
e.t. how to run process on my remote computer in interective window ?
|
|
|
|
 |
|
|
 |
|
 |
Any solution for what?
Works perfectly fine here. I just re-ran the samples against several 2003 servers from XP and Vista workstations and they all ran flawlessly.
Creating Process: notepad.exe
Successful(Completion)
Setting Process Priority: Idle
Process Owner: developer
Process Owner SID: S-1-5-21-3087281821-956584911-1637330626-1118
Properties of Process: notepad.exe
Caption: notepad.exe
CommandLine: notepad.exe
CreationClassName: Win32_Process
CreationDate: 20101012170109.859190-240
CSCreationClassName: Win32_ComputerSystem
CSName: BAILEYWEB01
Description: notepad.exe
ExecutablePath: C:\WINDOWS\system32\notepad.exe
Handle: 3024
HandleCount: 29
KernelModeTime: 1093750
MaximumWorkingSetSize: 1380
Memory Usage: 2204
MinimumWorkingSetSize: 200
Name: notepad.exe
OSCreationClassName: Win32_OperatingSystem
OSName: Microsoft Windows Server 2003 R2 Enterprise Edition|C:\WINDOWS|\Device\Harddisk0\Partition1
OtherOperationCount: 62
OtherTransferCount: 40
PageFaults: 632
PageFileUsage: 728
ParentProcessId: 3072
PeakPageFileUsage: 788
PeakVirtualSize: 29417472
PeakWorkingSetSize: 2204
Priority: 4
PrivatePageCount: 745472
ProcessId: 3024
QuotaNonPagedPoolUsage: 2
QuotaPagedPoolUsage: 43
QuotaPeakNonPagedPoolUsage: 3
QuotaPeakPagedPoolUsage: 58
ReadOperationCount: 0
ReadTransferCount: 0
SessionId: 0
ThreadCount: 1
UserModeTime: 156250
VirtualSize: 22614016
WindowsVersion: 5.2.3790
WorkingSetSize: 2256896
WriteOperationCount: 0
WriteTransferCount: 0
Killing Process: notepad.exe
Process Terminated
modified on Tuesday, October 12, 2010 5:01 PM
|
|
|
|
 |
|
 |
No offense, I think that all your articles here on CP are great and they helped me alot. But this one is not working for me. I get the same error as user iro4es (HRESULT: 0x80070005 (E_ACCESSDENIED)).
Is this maybe a cross domain isue ? I'm in one domain and the another computer is in another domain. For this another computer I have both local and domain administrator account.
Best regards, Bostjan
|
|
|
|
 |
|
 |
No sweat bro. Yea, I can do cross domain just fine but only if there is a trust relationship established in the forest between the two domains.
|
|
|
|
 |
|
 |
Thanks!
I'll ask our IT staff if we have trust relationship established betwen our two domains. Probably this will solve my problems.
Best regards, Bostjan.
|
|
|
|
 |
|
 |
I asked our IT about trust relationship betwen our two domains and it is established.
I can list processes on remote machines and terminate them, but I can't start a new process. Any more ideas ?
This is the error I get. {"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"} Any idea how to debug/trobelshoot this ?
|
|
|
|
 |
|
 |
Absolutely the same situation.
What do we have to do?
Also, can you show your "CreateProcess" call?
|
|
|
|
 |
|
 |
Hi all,
i want to write an .net c# application which will start and remote application (e.g notepad.exe) and send afterwards text to it. It should be able to send commands(text/string) to a specific PID on a remote pc.
This is what i have already from an example code:
string remoteMachine = "localhost";
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", remoteMachine), connOptions);
manScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClas sprocessClass = new ManagementClass(manScope, managementPath, objectGetOptions);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = @"notepad.exe";
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
Console.WriteLine("Creation of the process returned: " + outParams["returnValue"]);
Console.WriteLine("Process ID: " + outParams["processId"]);
Console.ReadLine();
Can someone help me?
Thanks
Stephan
|
|
|
|
 |
|
 |
Trying to use UNC with this code snippet, the ManagementClass is failing out when I try to launch a setup.exe on a different computer:
\\machine1\setup.exe - does not work
however if I try to launch an app from machine 1 on machine 2 with
\\machine2\setup.exe this does work. Unfortunately I need to be able to launch remotely. Is this possible with this snippet? I am completely new to WMI coding.
|
|
|
|
 |
|
 |
Are you using my library? Either way, my CreateProcess method or the ManagementClass objects require that you specify a domain account that has permission on the remote machine to execute the process.
|
|
|
|
 |
|
 |
I am using the Win32_Process testing first, before I play around adding it to my project.
I switched it over to remote machine
ProcessRemote process = new ProcessRemote("id", "pass", "domain", "machinetoinstallto");
I tested this with notepad and saw it run on the machine correctly.
I am trying to then run the string:
string processName = @"\\machinetoinstallfrom\Support\Change_Server_Names.exe";
and it errors out on: foreach (ManagementObject item "in" searchProcedure.Get()), "in" is throwing an invalid query.
The following does work though: string processName = @"\\machinetoinstallto\c$\Change_Server_Names.exe"; which to me tells me UNC works but its not letting me run it from a different machine. Also, the console is failing telling me:
Creating Process \\machinetoinstallfrom\Support\Change_Server_Names.exe
Access <Denied>
Setting Process Priority: Idle
I have full permissions on both machines and am a domain admin.
Thanks for any help you can provide.
|
|
|
|
 |
|
 |
Ok, so the reason why notepad runs without having to specify a path is because it's executable exists in one of your $PATH directories (c:\windows;c:\windows\system32, etc, etc). I have never tried to call an executable using UNC that way so I can't be much help there. My company has used this library (heavily modified over the years) in lots of projects; for example, in conjunction with PSTools and other management apps.
I have a few pointers for you to investigate though. First, when you call the method "CreateProcess" you're invoking the Win32_Process.Create() WMI method in the \\machinename\root\CIMV2 namespace. So any syntax you use has to be WMI compliant, in other words, it could be used in a WMI VBScript or PowerShell script etc. I don't know about using UNC via WMI, its been a long time since I had to work directly with WMI (we abstracted everything in WMI a long time ago).
You might also look at the ProcessConnectionOptions() method in the ProcessConnection object. There is a ConnectionOptions.Authentication.AuthenticationLevel enumeration setting for the default authentication level for the connection. We have it set to Default, which means that we allow WMI to handle our authentication, but you can change that to PacketLevel or other types if your environment runs kerberos or some other more strict domain authentication.
Hope This Helps,
T3
|
|
|
|
 |
|
 |
I'm using VS2005 and winXP pro SP2.
I get that error when trying to running it to remote machine(Win2003 Server), but I can use your remote registry. I'm using user: Administrator for win2k3.
Should I do something in the server first?
|
|
|
|
 |
|
|
 |
|
 |
If you plan to do more articles an idea would be something about printing and printers
|
|
|
|
 |
|
 |
Ha... funny you should mention that since I just posted part 3 which is all about WMI hardware properties aggragation and I specifically left our Win32_Printer since it deserves its own article.
|
|
|
|
 |
|
|
 |
|
 |
No problem. From the response of the 1st article I was thinking I was the last remaining developer still using WMI.
|
|
|
|
 |
|
 |
I've used it extensivly in vbscript for starting and stopping groups of services etc. I think if you know about this sort of stuff it adds more strings to your bow. Keep it up.
Jamsey
|
|
|
|
 |
|
|
 |
|
 |
WMI is not only here and active, but I used it just the other day as the only (best) solution. For IIS6 (aka the current production server version of IIS), WMI is the most cutting-edge API for manipulating IIS settings, so that's what I used.
A couple other things I've noticed about WMI from .NET 2.0 - it's easier than most of the articles I've read if you use the management objects directly.
Lastly, and perhaps even better, there is a tool for automatically generating strongly typed classes for WMI. It's called Mgmtclassgen.exe and is included in the standard .NET 2.0 SDK.
Party on, Ted.
|
|
|
|
 |
|
 |
WOW, that's a great tip (Mgmtclassgen.exe)! I have never heard of this before but I'm gonna check it out right away. I've been writing my own WMI classes now for years since the Management objects were so difficult to work with.
|
|
|
|
 |
|
 |
now, I want to excute remote process that is a Command line exe by wmi, then get the process result to local, the result is not the return code(for example returnValue etc). I want to directly get the result from the command line. how to do it, please help me, thank you very much.
|
|
|
|
 |