C
clteh9
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 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");
}}}