lyron
lyron

Reputation: 246

Running system command from C++ application differs from commandline

I want to execute a command from a C++ application. I do so using:

system("sendEmail.exe -f [email protected] -t ...");

This works on Windows Server 2008 and also on other systems. However, it does not work the same on my new server (Windows Server 2012), it seems to call the command but never completes. If I type the exact same command in a command window it works just fine.

I tried using

system("cmd.exe /C \"sendEmail.exe -f [email protected] -t ...\""); 

but that did not help.

Anyone has an idea whats the difference between calling from C++ with system and running in a cmd?

Edit: The problem is not reproducible any more. Thanks for the fast answers

Upvotes: 0

Views: 353

Answers (1)

sb9
sb9

Reputation: 1082

Try with

system("cmd.exe");

without parameters This will just open a cmd window and leave it open. From that window you can call sendMail.exe and see what's happening. Perhaps there's just a different path setting or a permission issue.

As an alternative you can use the Windows Api function CreateProcess

Upvotes: 3

Related Questions