473,416 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

regarding WMI -- Start process in remote machine

115 100+
i'm tring to start a calculator in a remote machine from my system. and the codes i tried is this.

Module Module1
Sub Main()
Dim retValue As String
retValue = RunCommand("calc.exe", "MachineName", "MachineName\UserID", "Password")
Console.WriteLine(retValue)
End Sub

Function RunCommand(ByVal strCommand As String, ByVal strMachineName As String, ByVal strUserName As String, ByVal strPassword As String) As String
Dim options As New System.Management.ConnectionOptions
options.Username = strUserName
options.Password = strPassword
options.Impersonation = Management.ImpersonationLevel.Impersonate
options.Authentication = Management.AuthenticationLevel.PacketPrivacy

Dim path As New System.Management.ManagementPath("\\" & strMachineName & "\root\cimv2:Win32_Process")
Dim scope As New System.Management.ManagementScope(path, options)

scope.Connect()

Dim opt As New System.Management.ObjectGetOptions
Dim classInstance As New System.Management.ManagementClass(scope, path, opt)

Dim inParams As System.Management.ManagementBaseObject = classInstance.GetMethodParameters("Create")
inParams("CommandLine") = strCommand

' Execute the method and obtain the return values.
Dim outParams As System.Management.ManagementBaseObject = classInstance.InvokeMethod("Create", inParams, Nothing)
Return "ReturnValue:" & outParams("returnValue") & " Process ID: {0}" & outParams("processId")

End Function

End Module

******while i tried to connect to some machines this error occurs.

An unhandled exception of type 'System.UnauthorizedAccessException' occurred in system.management.dll
Additional information: Access is denied.

*******and to someother machines and to the local machine this error occurs.

An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

Additional information: Cast from type 'UInt32' to type 'String' is not valid.

and my local machine the calculator is poping up and this above error occurs. but while connecting to remote machine, to some machine access is denied to some other the above error occurs and calc is not popping up too.

and one have anyidea what's wrong with my codes... please help me.
thanks in advance.
May 11 '07 #1
1 2883
remya1000
115 100+
i'm able to terminate the program from remote machine's(the program is opened manually). but while trying to open the program, the program is opened in the background in task manager. but i need to pop up the program.
and i commented this line
Return "ReturnValue:" & outParams("returnValue") & " Process ID: {0}" & outParams("processId")

so the error gone now. but need to display the calculator in front. not in taskmanager.
anyidea how to make the calculator display in screen. if u have anyidea please let me know.
thanks in advance
May 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sandiyan | last post by:
Hi, I am trying to use java to do the following: Remote machine(Windows): Has a drive mapped(m:\) to a network share. Invoking a BAT file(test.BAT) from this drive will install an application...
2
by: Peter | last post by:
Does anyone have a C# example either in managed code or using WMI on how to start a process on a remote computer? -- Thanks ------------------- czupet@wsinc.com
5
by: hangten | last post by:
I have a service that 1) uses filewatcher to watch a directory on a remote machine. 2) checks if a certain application is running on the local machine before starting it. The problem is while...
7
by: Denis Brkljacic | last post by:
Hi, I have made some simple ASP.NET (C#) application, that somewhere uses this command: Process aProcesses = Process.GetProcesses(Environment.MachineName); This command purpose is to find...
5
by: Dan Pavel | last post by:
Hi, I am starting a new process (Notepad) on a remote machine but it is not visible. When I start it on my machine it is visible. What I am doing wrong ? private void run_notepad(string machina)...
2
by: Matthew Lee | last post by:
I am using a C# / ASP.NET application to fire an XCOPY job from the webserver to a UNC share. This setup works fine when copying to a local machine but refuses to work on the remote copy. The...
2
by: Michael Isaacs | last post by:
Is there any way to share an object or variable between applications other than through .NET remoting? Also, if this is the only way, what kind of overhead is there for storage (memory) and speed...
3
by: Billy Bob | last post by:
Hello In C# how can i start a remote process such as someapp.exe on a remote PC? I know the remote PC's name, but how do I start the app on that PC? Thanks ..
4
omerbutt
by: omerbutt | last post by:
hi every one I am A new Bee to php mysql and i was surfing through the net to learn about how to secure the mysql when you are working in a web environment while working with php html and javascript...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.