473,320 Members | 2,092 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,320 software developers and data experts.

System.Management - Call Remote Script

There is no error or exception for the code below. It works fine with
the calc.exe. But it fails when i call the script. For your
information, strScript is the remote script and strFileName is the
arguments that passed in to the remote script. May i know anything
wrong to the source code below. Thanks

public void InvokeRemoteScript(string strScript, string strFileName)
{
if(this.m_mgmtScope != null && this.m_mgmtScope.IsConnected)
{
try
{
ManagementClass processClass = new ManagementClass("Win32_Process");
processClass.Scope = this.m_mgmtScope;

ManagementBaseObject inParms =
processClass.GetMethodParameters("Create");
inParms["CommandLine"] = String.Format("{0} {1}", strScript,
strFileName);
//inParms["CommandLine"] = "calc.exe";
ManagementBaseObject OutParms = processClass.InvokeMethod("Create",
inParms, null);

if(OutParms["ReturnValue"].ToString().Equals("0"))
{
//success
}
else
{
throw new Exception();
}
}
catch
{
throw new Exception("Failed to invoke the remote script");
}}}

Dec 10 '06 #1
1 1910
<cl****@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
There is no error or exception for the code below. It works fine with
the calc.exe. But it fails when i call the script. For your
information, strScript is the remote script and strFileName is the
arguments that passed in to the remote script. May i know anything
wrong to the source code below. Thanks

public void InvokeRemoteScript(string strScript, string strFileName)
{
if(this.m_mgmtScope != null && this.m_mgmtScope.IsConnected)
{
try
{
ManagementClass processClass = new ManagementClass("Win32_Process");
processClass.Scope = this.m_mgmtScope;

ManagementBaseObject inParms =
processClass.GetMethodParameters("Create");
inParms["CommandLine"] = String.Format("{0} {1}", strScript,
strFileName);
//inParms["CommandLine"] = "calc.exe";
ManagementBaseObject OutParms = processClass.InvokeMethod("Create",
inParms, null);

if(OutParms["ReturnValue"].ToString().Equals("0"))
{
//success
}
else
{
throw new Exception();
}
}
catch
{
throw new Exception("Failed to invoke the remote script");
}}}

The code you posted hides the most important part - m_mgmtScope - and you don't tell us what
exception you got either.

Willy.

Dec 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sean Erwin | last post by:
I am having a very frustrating intermittent problem. I am making an A2A call to a remote server and when I issue the: WebRequest.getResponse call it occasionally fails with the following error: ...
2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
1
by: nabilo | last post by:
I want to know if it's possible to call, within my cgi page, using javascript, a remote url and get the result without changing my actual page. To say more, I have a page result appaired to the...
3
by: Marshall | last post by:
Hello, I am wondering if it is possible to call a remote web service using ATLAS and if so, how. I have read several docs which show how to call a web service that is within the same project as...
2
by: fReDiNi | last post by:
Hi, I have being trying fo find the best solution for this problem for 2 days now and I am not able to find a solution.I need help. I explain the problem: A customer needs a system so that...
3
by: johnny | last post by:
I have a remote script on a local network and I need to make Web App in PHP, call this remote script on a different machine. How do I do this? Many Thanks.
8
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i trying to collect windows services. i'm getting inconsistencies. the collection works every time locally. but remote collection yields different result depending on my lab environment. 1) in...
0
by: trazcure | last post by:
Hi everyone, my name is Traz I'm trying to write some C# code that will check for remote disk space on network shares. I have seen across the internet and MSDN that you can utilize the...
3
by: sdDirtySox | last post by:
Hi all, I'm using system to invoke a script remotely on another machine. Something like this: system("/putty/plink.exe" 10.0.0.25 /home/foo); The problem is, sometimes the foo script freezes...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.