使用Params在CMD中运行多行,每行来自Windows RUN?

时间:2017-09-20 01:46:36

标签: cmd

我正在尝试使用Run选项(win + R)通过CMD设置powercfg的最大cpu限制。我尝试过多个网站的多种组合,但都没有。我做错了什么。

CMD中使用的一行:

Powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN 50

CMD中使用的第二行

Powercfg -setactive scheme_current

通过CMD设置powercfg调整需要输入2行。

我尝试过的组合失败:

CMD /k ""C:\Windows\System32\cmd.exe" "Powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN 50"" & ""C:\Windows\System32\cmd.exe" "Powercfg -setactive scheme_current""

CMD /k ""C:\Windows\System32\cmd.exe" "Powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN 50"" && ""C:\Windows\System32\cmd.exe" "Powercfg -setactive scheme_current""

CMD /k "Powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN 50" & "Powercfg -setactive scheme_current"

CMD /k ""C:\Windows\System32\cmd.exe" "Powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN 100" & "Powercfg -setactive scheme_current""

CMD /k ""C:\Windows\System32\cmd.exe" "Powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN 100" && "Powercfg -setactive scheme_current""

我正在使用一个程序(短语表达)来基于自定义关键字的检测来替换文本,因此这使得该过程非常快,而无需手动输入所有行。所以我可以输入CPUTHROTTLE>替换代码>提示PROCTHROTTLEMIN varitable(这是50的位置)>输入

2 个答案:

答案 0 :(得分:2)

这个怎么样:

    date_default_timezone_set('Asia/Taipei');
    $CurTime = date('Y-m-d H:i:s');
    $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);

    if(!$link){
        die('Failed to connect to server: ' . mysqli_error());
    } 

    //Select database
    $db = mysqli_select_db($link,DB_DATABASE);

    if(!$db){
        //Do auto download of database in the Server automatically
        if(file_exists('Database/'.DB_DATABASE.'.sql')){
            mysqli_query($link,"CREATE DATABASE ".DB_DATABASE);
            $db = mysqli_select_db($link,DB_DATABASE);
            $readContent = file_get_contents("Database/".DB_DATABASE.".sql");
            $res = mysqli_multi_query($link,$readContent) or die(mysqli_error($link));
            mysqli_close($link);
        } else {
        die("Unable to select database, Please call your system administrator. Thank you.");    
        }
    }

    function Reload_Database($DBLink){
        if(file_exists($DBLink)){
            //mysqli_query($link,"DROP DATABASE ".DB_DATABASE);
            //mysqli_query($link,"CREATE DATABASE ".DB_DATABASE);
            $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
            $db = mysqli_select_db($link,DB_DATABASE);
            $readContent = file_get_contents($DBLink);
            $res = mysqli_multi_query($link,$readContent) or die(mysqli_error($link));
            mysqli_close($link);
            return 'Database Reloaded';
        } else {
            die("Unable to reload database, Please call your system administrator. Thank you.");    
        }
    }

echo Reload_Database('../employee/database/'.DB_DATABASE.'.sql');

或者这个:

Powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {Powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN 50;Powercfg -setactive scheme_current}"

答案 1 :(得分:0)

我建议将命令放在参数化批处理脚本cputhrottle.cmd中,如下所示:

@echo off
powercfg -setacvalueindex scheme_current sub_processor PROCTHROTTLEMIN %~1
powercfg -setactive scheme_current

并将脚本保存到PATH中的文件夹中。这样您就可以从“运行”对话框中运行cputhrottle 50