system() equivalent in Windows

Hi,
I am trying to port a test suite present in linux to WinCE 5.0.

I am trying to find a way of executing the shell commands like ipconfig, set etc on a WinCE device that doesnot have a “command prompt”.

What i am trying is, the following 2 lines of code:

sprintf(gCmdStr, “ipconfig”…);
system(gCmdStr);

when executed on a Llinux system would execute as a system command and return the ip address and stuff like that.

I know a similar way of executing the ipconfig command on WinCE ie using
CreateProcess() and calling the “cmd.exe” and passing the "ipconfig " as the command line arguement.

But i am not able to find a way to execute the commands like ipconfig, set etc on WinCE devices that do not have command-prompt support.

How can this be accomplished?

Any suggestions in this regard is highly appreciated.

Why can’t you just run/shell the “ipconfig” executable direct withing
launching it via cmd?

BR,

Rob Linegar
Software Engineer
Data Encryption Systems Limited
www.des.co.uk | www.deslock.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: 18 September 2007 10:03
To: Windows System Software Devs Interest List
Subject: [ntdev] system() equivalent in Windows

Hi,
I am trying to port a test suite present in linux to WinCE 5.0.

I am trying to find a way of executing the shell commands like ipconfig,
set etc on a WinCE device that doesnot have a “command prompt”.

What i am trying is, the following 2 lines of code:

sprintf(gCmdStr, “ipconfig”…);
system(gCmdStr);

when executed on a Llinux system would execute as a system command and
return the ip address and stuff like that.

I know a similar way of executing the ipconfig command on WinCE ie using

CreateProcess() and calling the “cmd.exe” and passing the "ipconfig " as
the command line arguement.

But i am not able to find a way to execute the commands like ipconfig,
set etc on WinCE devices that do not have command-prompt support.

How can this be accomplished?

Any suggestions in this regard is highly appreciated.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hi,

Check out the windows API “ShellExecuteEx”.

Regards,
Elango C

On 9/18/07, xxxxx@hotmail.com
wrote:
>
> Hi,
> I am trying to port a test suite present in linux to WinCE 5.0.
>
> I am trying to find a way of executing the shell commands like ipconfig,
> set etc on a WinCE device that doesnot have a “command prompt”.
>
> What i am trying is, the following 2 lines of code:
>
> sprintf(gCmdStr, “ipconfig”…);
> system(gCmdStr);
>
> when executed on a Llinux system would execute as a system command and
> return the ip address and stuff like that.
>
> I know a similar way of executing the ipconfig command on WinCE ie using
> CreateProcess() and calling the “cmd.exe” and passing the "ipconfig " as
> the command line arguement.
>
> But i am not able to find a way to execute the commands like ipconfig,
> set etc on WinCE devices that do not have command-prompt support.
>
> How can this be accomplished?
>
> Any suggestions in this regard is highly appreciated.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


Elango C
CompuApps, Inc.
Chennai, India.
website:http://celango.blogspot.com

xxxxx@hotmail.com wrote:

I am trying to port a test suite present in linux to WinCE 5.0.

I am trying to find a way of executing the shell commands like ipconfig, set etc on a WinCE device that doesnot have a “command prompt”.

Most CE devices include cmd.exe. Have you tried executing it by hand in
Start->Run?

What i am trying is, the following 2 lines of code:

sprintf(gCmdStr, “ipconfig”…);
system(gCmdStr);

when executed on a Llinux system would execute as a system command and return the ip address and stuff like that.

I know a similar way of executing the ipconfig command on WinCE ie using
CreateProcess() and calling the “cmd.exe” and passing the "ipconfig " as the command line arguement.

But i am not able to find a way to execute the commands like ipconfig, set etc on WinCE devices that do not have command-prompt support.

How can this be accomplished?

ipconfig.exe is a standalone executable. Just run IT with
CreateProcess. No need to involve a command processor. You will have
to use a pipe to connect to the stdout of the process so you can read
the output.

However, if the device doesn’t include cmd.exe, then it seems very
unlikely that it would have command-line tools like ipconfig.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

If you look for the “Process” documentation for C# in .NET, Microsoft has a
small example there that starts a process and redirects input and output. I
have a fragment of a toy I gave to my students last semester, hope this
helps. Note that in this case the program and the argument strings come from
two Text Boxes that get acted upon when the user clicks a “Run” button: the
runButton_Click(…) function is its event handler.

Hope this helps! However, I don’t know how much .NET is implemented on
WinCE.

Alberto.

=======================
private void OutputHandler(object sender, DataReceivedEventArgs line)
{
if (!String.IsNullOrEmpty(line.Data))
{
sb.Append(line.Data);
outBox.Text += line.Data;
outBox.Text += “\n”;
}
}

private void runButton_Click(object sender, EventArgs e)
{
string prog = argBox.Text;
string args = argBox.Text;
Process p = new Process();
p.StartInfo.FileName = prog;
p.StartInfo.Arguments = args;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
sb = new StringBuilder(“”);
p.OutputDataReceived += new
DataReceivedEventHandler(OutputHandler);
p.Start();
p.BeginOutputReadLine();
}

----- Original Message -----
From: “Rob Linegar”
To: “Windows System Software Devs Interest List”
Sent: Tuesday, September 18, 2007 5:20 AM
Subject: RE: [ntdev] system() equivalent in Windows

Why can’t you just run/shell the “ipconfig” executable direct withing
launching it via cmd?

BR,

Rob Linegar
Software Engineer
Data Encryption Systems Limited
www.des.co.uk | www.deslock.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: 18 September 2007 10:03
To: Windows System Software Devs Interest List
Subject: [ntdev] system() equivalent in Windows

Hi,
I am trying to port a test suite present in linux to WinCE 5.0.

I am trying to find a way of executing the shell commands like ipconfig,
set etc on a WinCE device that doesnot have a “command prompt”.

What i am trying is, the following 2 lines of code:

sprintf(gCmdStr, “ipconfig”…);
system(gCmdStr);

when executed on a Llinux system would execute as a system command and
return the ip address and stuff like that.

I know a similar way of executing the ipconfig command on WinCE ie using

CreateProcess() and calling the “cmd.exe” and passing the "ipconfig " as
the command line arguement.

But i am not able to find a way to execute the commands like ipconfig,
set etc on WinCE devices that do not have command-prompt support.

How can this be accomplished?

Any suggestions in this regard is highly appreciated.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Um, guys, what about different approach? Parsing program output is unixish way; we use APIs for similar tasks at Windows. Blindly porting code from different OS isn’t a good idea. ipconfig output isn’t part of any specification, I guess, and can change with every WinCE revision. I’m not sure if everything what ipconfig outputs can be found documented way but WinCE sources are available and ipconfig implementation can be examined.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Alberto Moreira[SMTP:xxxxx@ieee.org]
Reply To: Windows System Software Devs Interest List
Sent: Wednesday, September 19, 2007 3:51 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] system() equivalent in Windows

If you look for the “Process” documentation for C# in .NET, Microsoft has a
small example there that starts a process and redirects input and output. I
have a fragment of a toy I gave to my students last semester, hope this
helps. Note that in this case the program and the argument strings come from
two Text Boxes that get acted upon when the user clicks a “Run” button: the
runButton_Click(…) function is its event handler.

Hope this helps! However, I don’t know how much .NET is implemented on
WinCE.

Alberto.

=======================
private void OutputHandler(object sender, DataReceivedEventArgs line)
{
if (!String.IsNullOrEmpty(line.Data))
{
sb.Append(line.Data);
outBox.Text += line.Data;
outBox.Text += “\n”;
}
}

private void runButton_Click(object sender, EventArgs e)
{
string prog = argBox.Text;
string args = argBox.Text;
Process p = new Process();
p.StartInfo.FileName = prog;
p.StartInfo.Arguments = args;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
sb = new StringBuilder(“”);
p.OutputDataReceived += new
DataReceivedEventHandler(OutputHandler);
p.Start();
p.BeginOutputReadLine();
}

----- Original Message -----
From: “Rob Linegar”
> To: “Windows System Software Devs Interest List”
> Sent: Tuesday, September 18, 2007 5:20 AM
> Subject: RE: [ntdev] system() equivalent in Windows
>
>
>
> Why can’t you just run/shell the “ipconfig” executable direct withing
> launching it via cmd?
>
> BR,
>
> Rob Linegar
> Software Engineer
> Data Encryption Systems Limited
> www.des.co.uk | www.deslock.com
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of
> xxxxx@hotmail.com
> Sent: 18 September 2007 10:03
> To: Windows System Software Devs Interest List
> Subject: [ntdev] system() equivalent in Windows
>
> Hi,
> I am trying to port a test suite present in linux to WinCE 5.0.
>
> I am trying to find a way of executing the shell commands like ipconfig,
> set etc on a WinCE device that doesnot have a “command prompt”.
>
> What i am trying is, the following 2 lines of code:
>
> sprintf(gCmdStr, “ipconfig”…);
> system(gCmdStr);
>
> when executed on a Llinux system would execute as a system command and
> return the ip address and stuff like that.
>
> I know a similar way of executing the ipconfig command on WinCE ie using
>
> CreateProcess() and calling the “cmd.exe” and passing the "ipconfig " as
> the command line arguement.
>
> But i am not able to find a way to execute the commands like ipconfig,>
> set etc on WinCE devices that do not have command-prompt support.
>
> How can this be accomplished?
>
> Any suggestions in this regard is highly appreciated.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

Ipconfig (in CE) uses the public interface of IPHLPAPI.DLL (the IP Helper
APIs) to collect the information it displays.

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michal Vodicka
Sent: Tuesday, September 18, 2007 10:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] system() equivalent in Windows

Um, guys, what about different approach? Parsing program output is unixish
way; we use APIs for similar tasks at Windows. Blindly porting code from
different OS isn’t a good idea. ipconfig output isn’t part of any
specification, I guess, and can change with every WinCE revision. I’m not
sure if everything what ipconfig outputs can be found documented way but
WinCE sources are available and ipconfig implementation can be examined.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]