简体   繁体   English

未从批处理脚本接收参数

[英]Not receiving arguments from batch script

I've created a simple program for moving files around in a system running win 7 embedded. 我创建了一个简单的程序,用于在运行Win 7 Embedded的系统中移动文件。 I've run into a strange "bug" with my software and the way it handles startups. 我的软件及其处理启动的方式遇到了一个奇怪的“错误”。

    static void Main(string[] args)
    {
        if (Flagger.GetFlag().Contains("Processing") || args.Contains("batch"))
        {
            Run();
        }
        return;
    }

The way I've chosen to handle the different ways this program will be executed, I've created a simple way of seeing whether it is being executed as a part of the systems startup procedure, or called by a batch file. 我选择处理该程序执行方式不同的方式,我创建了一种简单的方法来查看它是作为系统启动过程的一部分执行,还是由批处理文件调用。

The batch file is meant to be called by a trigger in the SQL-server and run a handful of programs for logging and such. 批处理文件旨在由SQL Server中的触发器调用,并运行少数程序进行日志记录等。 While testing this on my workstation it executes and passes the parameters like it is supposed to do, but in the embedded system, no parameters is given to the program through the batch file. 在我的工作站上进行测试时,它会像预期的那样执行并传递参数,但是在嵌入式系统中,没有通过批处理文件将参数提供给程序。

start Pack.exe -batch
exit

I have tried several different methods of writing the batch file(with/without citation marks, start-exit) but to no avail. 我尝试了几种写批处理文件的方法(带/不带引号,开始-退出),但无济于事。 What could be causing the batch file to not pass the arguments to the Packer? 是什么导致批处理文件未将参数传递给打包程序?

Starts a separate window to run a specified program or command.
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/WAIT] [/B] [command/program]
[parameters]

Could it be, that you're passing qouted string as the first parameter to start command? 难道您要传递qouted字符串作为启动命令的第一个参数? If so, it handles it like a window title. 如果是这样,它将像窗口标题一样处理它。 Compare 相比

start "c:\windows\notepad.exe"

and this 和这个

start "test" "c:\windows\notepad.exe"

Then you should just add a title param to start program. 然后,您只需添加标题参数即可启动程序。 Also consider to use cmd /C instead. 还可以考虑使用cmd / C代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM