[Interest] QProcess to start a process at a higher priority

NoMercy nomercy at gmail.com
Tue Mar 10 16:15:56 CET 2015


Hello again,
for that I have something like this (if you have a static number of
arguments);

Set WshShell = CreateObject("WScript.Shell")
>
> WshShell.currentdirectory = "C:\Program Files\your_app_dir"
>
> 'wscript.echo WshShell.currentdirectory
>
> WshShell.Run chr(34) & "C:\Program Files\ your_app_dir\your_bat.bat" &
>> chr(34) & " " & Wscript.Arguments(0) & " " & Wscript.Arguments(1) , 0
>
> Set WshShell = Nothing
>
>
Happy Coding
Emre

On Tue, Mar 10, 2015 at 5:09 PM, Jason Kretzer <Jason at gocodigo.com> wrote:

> Thanks!
>
> Honestly, I do not have much experience with Vbscript.  In your example
> below, how would I pass arguments to the your_bat.bat?  I have 8 quoted
> arguments that I need to pass the bat file.
>
> I have tried this
>
> Dim arg0
> arg0 = WScript.Arguments.Item(0)
> WScript.Echo arg0
> WshShell.Run chr(34) & "C:\Program Files\yourapp\your_bat.bat" & arg0 &
> chr(34) , 0
>
> But that is not quite right.  It echos the arg0 fine but I get a “The
> system cannot find the file specified” when I run that.
>
> Thoughts?
>
> -Jason
>
> //------------------------------//
>    Jason R. Kretzer
>    Lead Application Developer
>    Jason at gocodigo.com
> //-----------------------------//
>
>
> From: NoMercy <nomercy at gmail.com>
> Date: Monday, March 9, 2015 at 5:27 AM
> To: "Jason R. Kretzer" <jason at gocodigo.com>
> Subject: Re: [Interest] QProcess to start a process at a higher priority
>
> Our app uses an ugly method for exactly this reason and I intend to
> research and find a better solution on this subject when I have time but
> for the moment we use "cscript.exe /path/to/your/script.vbs"
> in vbs:
>
> Set WshShell = CreateObject("WScript.Shell")
>>
>> WshShell.currentdirectory = "C:\Program Files\ yourapp"
>>
>> 'wscript.echo WshShell.currentdirectory
>>
>> WshShell.Run chr(34) & "C:\Program Files\yourapp\your_bat.bat" & chr(34)
>>> , 0
>>
>> Set WshShell = Nothing
>>
>>
> And if I'm remembering correctly the zero ("0") at the end of line that
> starts with "WshShell.Run" makes it windowless.
>
> Happy coding
> Emre
>
> On Mon, Mar 9, 2015 at 1:53 AM, Jason Kretzer <Jason at gocodigo.com> wrote:
>
>> Hello all,
>>
>> I am tinkering a bit with QProcess on Windows7.  What I would like to be
>> able to do is to start a process with a “high” priority.  My application
>> spawns multiple processes and I am tinkering with them in order to help
>> ensure they get their processor time.
>>
>> On the command line, I would do this.
>>
>> start /high myspawn.exe arg1 arg2 arg3
>>
>> Unfortunately one of the requirements is that a DOS window not open to
>> run it.
>>
>> If I start the process like this:
>>
>> QString program = “myspawn.exe";
>> QStringList arguments;
>>
>> arguments << “arg1” << “arg2" << “arg3";
>>
>> QProcess *p = new QProcess(this);
>> QTimer::singleShot(30000, this, SLOT(deleteLater()));
>> qDebug() << "starting mysawn process -- " << p->startDetached(program,
>> arguments);
>>
>> It starts just fine, no DOS window, but at Normal priority.
>>
>> I have tried multiple ways using the “start /high…” command inside of the
>> various ways to execute a command with QProcess, but they always flash a
>> DOS window.
>>
>> I even create a .bat file with the command in it and passed arguments in
>> with the above code.  While it worked, it flashed the DOS window.
>>
>> Am I missing something here?
>>
>> -Jason
>>
>> //------------------------------//
>>    Jason R. Kretzer
>>    Lead Application Developer
>>    Jason at gocodigo.com
>> //-----------------------------//
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
> ------------------------------
>
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2015.0.5645 / Virus Database: 4299/9221 - Release Date: 03/03/15
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150310/7043809b/attachment.html>


More information about the Interest mailing list