/// <summary>
 /// 强制释放连接以及所占用的文件
 /// </summary>
 public static void ResetConnection()
 {
     if (GetConnection().State != ConnectionState.Closed)
     {
         SystemCommandUtil.ExecuteCommand("taskkill /fi \"imagename eq sqlservr.exe\" /f");
     }
 }
Пример #2
0
        /**
         * 关机指令的内部实现
         */
        private static void RunShutdownCommand(Mode mode, int seconds)
        {
            if (DEBUG_MODE)
            {
                return;
            }
            String command = "shutdown ";

            switch (mode)
            {
            case Mode.关机:
                command += "-s -t " + seconds;
                break;

            case Mode.重启:
                command += "-g -t " + seconds;
                break;

            case Mode.取消:
                command += "-a";
                break;

            default:
                RunSuspendCommand(mode);
                return;
            }
            SystemCommandUtil.ExecuteCommand(command);
        }
Пример #3
0
 public static bool RemoveFileFromDisk(string fullFilename)
 {
     try
     {
         System.IO.File.Delete(fullFilename);
     }
     catch
     {
         SystemCommandUtil.ExecuteCommand("del \"" + fullFilename + "\"");
     }
     return(true);
 }