Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从WCF服务关闭或重新启动计算机不工作_Wcf_Acl_Wcfserviceclient - Fatal编程技术网

从WCF服务关闭或重新启动计算机不工作

从WCF服务关闭或重新启动计算机不工作,wcf,acl,wcfserviceclient,Wcf,Acl,Wcfserviceclient,我在IIS7.5中托管的WCF服务中有一个函数,它的任务是在调用计算机时关闭或重新启动计算机 我使用内置的命令行,通过传递“shutdown.exe-t0-r”重新启动或传递“shutdown.exe-t0-s”关闭来执行它 Try Using process As New System.Diagnostics.Process() Dim startInfo As New System.Diagnostics.ProcessStartInfo()

我在IIS7.5中托管的WCF服务中有一个函数,它的任务是在调用计算机时关闭或重新启动计算机

我使用内置的命令行,通过传递“shutdown.exe-t0-r”重新启动或传递“shutdown.exe-t0-s”关闭来执行它

    Try
        Using process As New System.Diagnostics.Process()
            Dim startInfo As New System.Diagnostics.ProcessStartInfo()
            With startInfo
                .WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
                .CreateNoWindow = True
                .UseShellExecute = False
                .RedirectStandardError = True
                .RedirectStandardInput = True
                .RedirectStandardOutput = True
                .FileName = "shutdown.exe"
                .Arguments = "-t 0 -r"
            End With
            If System.Environment.OSVersion.Version.Major >= 6 Then process.StartInfo.Verb = "runas"
            process.StartInfo = startInfo
            process.Start()
            process.WaitForExit()
            If process.ExitCode = 0 Then
                Return True
            Else
                Return False
            End If
        End Using
    Catch ex As Exception
        Return False
    End Try

如果在命令提示符下手动执行,命令行工作正常。但是,当它在WCF服务内部执行时,它不起作用。

我猜您的服务没有关闭pc的权限(我猜欠权限的用户是网络用户,不能这样做),我很肯定它包含了你问题的答案


查看如何在特定帐户下运行wcf服务

我猜您的服务没有关闭电脑的权限(我猜欠权限的用户是网络用户,不能这样做),我很肯定它包含了你问题的答案


查看如何在特定帐户下运行wcf服务

好吧,尝试了所有的方法,但都失败了,最后还是失败了。而且它是有效的

这太奇怪了,我还是不知道为什么它会起作用。现在…谁在乎呢:)…等我有空的时候,我会想办法解决的

        ....
        Dim strCmd As String = "SHUTDOWN -m {0} -f -t 0 -r"           
        File.WriteAllText(_pathCmd & "cmd_restart.bat", String.Format(strCmd, "127.0.0.1"))
        Return ExecuteCommand(_pathCmd & "cmd_restart.bat", "")

好吧,尝试了所有的事情,但都失败了,最终还是失败了。而且它是有效的

这太奇怪了,我还是不知道为什么它会起作用。现在…谁在乎呢:)…等我有空的时候,我会想办法解决的

        ....
        Dim strCmd As String = "SHUTDOWN -m {0} -f -t 0 -r"           
        File.WriteAllText(_pathCmd & "cmd_restart.bat", String.Format(strCmd, "127.0.0.1"))
        Return ExecuteCommand(_pathCmd & "cmd_restart.bat", "")

WCF服务以什么身份运行?您可能还希望将
-f
添加到参数中。wcf应用程序池作为localsystem运行。什么是-f参数?它强制运行的应用程序关闭:@slugster它仍然不工作。我认为通过使用localsystem标识,我们将拥有所有管理员权限。但这似乎不是它的工作原理。WCF服务运行的身份是什么?您可能还希望将
-f
添加到参数中。wcf应用程序池作为localsystem运行。什么是-f参数?它强制运行的应用程序关闭:@slugster它仍然不工作。我认为通过使用localsystem标识,我们将拥有所有管理员权限。但它似乎不是这样工作的。我尝试使用提供特定管理员凭据来运行该进程。然后我得到4个新的事件日志,上面写着:1。尝试使用显式凭据登录。2.已成功登录一个帐户。3.分配给新登录的特殊previledge。4.一个帐户已注销。但什么也没发生。不重启,不关机。没有。我尝试使用提供特定的管理员凭据运行进程。然后我得到4个新的事件日志,上面写着:1。尝试使用显式凭据登录。2.已成功登录一个帐户。3.分配给新登录的特殊previledge。4.一个帐户已注销。但什么也没发生。不重启,不关机。没有什么。