Scheduled tasks 调用SchTasks远程删除任务失败,C出现多连接错误

Scheduled tasks 调用SchTasks远程删除任务失败,C出现多连接错误,scheduled-tasks,Scheduled Tasks,在c代码中,我调用schtasks来删除一些计划任务。我打了第一个电话,返回了以下错误: 错误:不允许同一用户使用多个用户名多次连接到服务器或共享资源 以下是运行该流程的代码: Process stProc = new Process(); stProc.StartInfo.UseShellExecute = false; stProc.StartInfo.FileName = "SCHTASKS.exe"; stProc.Sta

在c代码中,我调用schtasks来删除一些计划任务。我打了第一个电话,返回了以下错误:

错误:不允许同一用户使用多个用户名多次连接到服务器或共享资源

以下是运行该流程的代码:

        Process stProc = new Process();

        stProc.StartInfo.UseShellExecute = false;
        stProc.StartInfo.FileName = "SCHTASKS.exe";
        stProc.StartInfo.RedirectStandardError = true;
        stProc.StartInfo.RedirectStandardOutput = true;
        stProc.StartInfo.CreateNoWindow = true;
        stProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        stProc.StartInfo.Arguments = args;

        stProc.Start();
        stProc.BeginOutputReadLine();
        stProc.BeginErrorReadLine();
        stProc.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
        stProc.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
        stProc.WaitForExit();
        stProc.Close();
        stProc.Dispose();
我的论点是正确的,具体如下:

为了确保我的连接没有挂起,我创建了一个新进程,在每次删除调用之前将其终止:

StartProcess(args);
        Process x = new Process();
        x.StartInfo.FileName = "cmd";
        x.StartInfo.Arguments = @" net use \\servername\ipc$ /delete";
        x.StartInfo.CreateNoWindow = true;
        x.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        x.Start();
不知道上面是什么。可能是其他人在使用这台机器,所以我的电话无法接通

任何想法都值得赞赏

谢谢

答案是:

我使用了机器的IP地址