• 通过web端启动关闭服务器程序以及检测程序运行状态


    #web端检测服务器程序运行,启动服务器程序,关闭服务器程序
    import os import sys import time import win32com.client def check_exsit(process_name): WMI = win32com.client.GetObject('winmgmts:') processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name like "%{}%"'.format(process_name)) if len(processCodeCov) > 0: return True else: return False def game_status(): examples = ["RSConsole.exe", "CSConsole.exe", "GSConsole.exe"] for example in examples : res = check_exsit(example) if not res : return False return True def game_stop(): examples = ["RSConsole.exe", "GSConsole.exe", "CSConsole.exe"] for example in examples : res = check_exsit(example) if res : os.system('taskkill /f /im ' + example) time.sleep( 1 ) return True def game_start(): examples = ["CSConsole.exe", "GSConsole.exe", "RSConsole.exe"] examples_path = {"CSConsole.exe" : "F:/Server_RC_ATT/WYYGame/Bin/x64/Debug", "GSConsole.exe" : "F:/Server_RC_ATT/WYYGame/Bin/x64/Debug/GSATT2", "RSConsole.exe" : "F:/Server_RC_ATT/WYYGame/Bin/x64/Debug"} for example in examples : cmd_line = 'start "' + example + '" /d "' + examples_path[example] + '" /MIN "' + example + '"' #需要注意在进程名字,路径加双引号 os.system(cmd_line) time.sleep( 5 ) return True if __name__ == '__main__': operationType = sys.argv[1] if "game_status" == operationType : print(game_status()) if "game_stop" == operationType : print(game_stop()) if "game_start" == operationType : game_stop() print(game_start())

      

    php端調用

    <?php 
    	$a = "game_start";
    	exec("python F:/Server_RC_ATT/WYYGame/Bin/x64/game_status.py $a", $out, $res);
    	for($i = 0; $i < count($out); $i++) {
    		echo $out[$i];
    		echo "<br>";
    	}
    	echo $res;
    ?>
    

      

  • 相关阅读:
    一个js选项卡
    郁闷
    Object Literals
    typeof and instanceof
    比较好用的日期控件
    很炫的分页
    [转]ASP.NET Web.config配置文件的基本使用方法
    正则匹配 获取QQ空间日志
    漂浮窗(层)JS
    ASP.NET页面事件执行过程(完整版)
  • 原文地址:https://www.cnblogs.com/hailong88/p/13398849.html
Copyright © 2020-2023  润新知