ServiceBase.Run 方法 (ServiceBase)  [C#]请参见
ServiceBase 类 | ServiceBase 成员 | System.ServiceProcess 命名空间 | ServiceBase.Run 重载列表 | ServiceBase | OnStart 
要求
平台: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
语言
C#C++JScriptVisual Basic全部显示
为包含单个服务的可执行文件提供主入口点。将服务加载到内存,以便可以启动该服务。[Visual Basic]
Overloads Public Shared Sub Run( _
   ByVal service As ServiceBase _
)
[C#]
public static void Run(
   ServiceBase service
);
[C++]
public: static void Run(
   ServiceBase* service
);
[JScript]
public static function Run(
   service : ServiceBase
);
参数
service 
ServiceBase,指示要启动的服务。 
异常
异常类型 条件 
Win32Exception 您试图从命令行启动服务。 备注
在该服务可执行文件的 main() 函数中调用此重载以加载单个服务。当在服务上调用 Run 时,该服务被加载到内存中。在“服务控制管理器”向服务传递“开始”命令之前,该服务不启动。调用 ServiceBase.Run 的方式与 Windows 窗体应用程序的“运行”十分类似。如果 AutoLog 为 true,则在 service 参数指定的服务启动失败时将向事件日志中写入一项。要求
平台: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family请参见
ServiceBase 类 | ServiceBase 成员 | System.ServiceProcess 命名空间 | ServiceBase.Run 重载列表 | ServiceBase | OnStart 

解决方案 »

  1.   

    没办法以前台方式运行:
    System.Diagnostics.ProcessStartInfo
    startInfo = new System.Diagnostics.ProcessStartInfo();
    System.Diagnostics.Process p;
    startInfo.FileName = "C:\\winnt\\system32\\net.exe";
    startInfo.Arguments = "send ntloginname The Message";
    startInfo.WindowStyle =
    System.Diagnostics.ProcessWindowStyle.Hidden;
    p = System.Diagnostics.Process.Start(startInfo);
    p.WaitForExit();
      

  2.   

    use System.Diagnostics.Process , see http://chrislewis.blogspot.com/
      

  3.   

    上是WinForm的,简单方式:
         Process proc = new Process();  
         proc.StartInfo.FileName = @"Notepad.exe";  
         proc.StartInfo.Arguments = "";  
         proc.Start(); 
      

  4.   

    例子:
    using System.Diagnostics;
    ......
    ProcessStartInfo psInfoCmd = new ProcessStartInfo();
    psInfoCmd.FileName = "dnscmd.exe";
                
    string strParameter = " "+ ServerName + " /recordadd " + Zone +" " + NodeName + " A " + IPData;
    psInfoCmd.Arguments = strParameter; Process Proc = null;
    try
    {
    Proc = Process.Start(psInfoCmd);
    }
    catch
    {
    //找不到文件
    } //进程没有正常退出
    Proc.WaitForExit(3000);
    if (Proc.HasExited != true)
    {
    Proc.Kill();
    }
      

  5.   

    请问acewang(**^o^**) ,组合命令怎么执行
    比如:at 10:02 net send wuc abc