regarding spawnProcess and parameters in Windows
Hugo Florentino
hugo at acdam.cu
Sun Dec 15 15:14:25 PST 2013
Hello,
I am trying to do a small launcher for a Windows application which (in
order to be portable) requires a specific parameter, and I am getting
this error when I try to run it in Windows 7 SP1:
"std.process.ProcessException at std\process.d(518): Failed to spawn new
process (Access denied.)"
This is the code I am trying to use:
import std.stdio, std.file, std.path, std.string, std.process;
static auto appname = "myapp";
int main(string[] args) {
auto appath = dirName(thisExePath());
auto appexe = buildPath(appath, appname ~ ".exe");
auto appini = buildPath(appath, appname ~ ".ini");
auto applaunchpars = format(`"%s" /ini="%s"`, appexe, appini);
if (exists(appexe)) {
auto appPid = spawnProcess(applaunchpars, ["" : ""],
Config.suppressConsole);
scope(failure) return -1;
}
return 0;
}
The ugly ["" : ""] hack is because I haven't been able to invoke
spawnProcess otherwise, at least withouth specifying stdin and stdout
(which I don't really need right now). Actually, I was thinking in
making my own wrapper for ShellExecuteA (I don't find spawnProcess
particularly intuitive), but I would prefer "the D way".
Anyway, Where could the problem be?
Regards, Hugo
More information about the Digitalmars-d-learn
mailing list