ShellExcute and System Path

I have Windows XP and Windows Vista PC's.
I need to use ShellExcute in my MFC application and run the dos ping command 
with a hidden window.
Can some gentleman here give the right syntax?
Regards
Ronny 


0
ronny6132 (3)
10/20/2008 10:21:17 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
510 Views

Similar Articles

[PageSpeed] 42

maybe IcmpSendEcho IcmpSendEcho2 IcmpSendEcho2Ex
can help you. a sample from MSDN:

#include <winsock2.h>
#include <iphlpapi.h>
#include <icmpapi.h>
#include <stdio.h>

#pragma comment(lib, "Iphlpapi.lib")
#pragma comment(lib, "Ws2_32.lib")

int __cdecl main(int argc, char **argv)  {

    // Declare and initialize variables

    HANDLE hIcmpFile;
    unsigned long ipaddr = INADDR_NONE;
    DWORD dwRetVal = 0;
    char SendData[] = "Data Buffer";
    LPVOID ReplyBuffer = NULL;
    DWORD ReplySize = 0;

    // Validate the parameters
    if (argc != 2) {
        printf("usage: %s IP address\n", argv[0]);
        return 1;
    }

    ipaddr = inet_addr(argv[1]);
    if (ipaddr == INADDR_NONE) {
        printf("usage: %s IP address\n", argv[0]);
        return 1;
    }

    hIcmpFile = IcmpCreateFile();
    if (hIcmpFile == INVALID_HANDLE_VALUE) {
        printf("\tUnable to open handle.\n");
        printf("IcmpCreatefile returned error: %ld\n", GetLastError() );
        return 1;
    }

    // Allocate space for at 8 replies
    ReplySize = 8* (sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));
    ReplyBuffer = (VOID*) malloc(ReplySize );
    if (ReplyBuffer == NULL) {
        printf("\tUnable to allocate memory for reply buffer\n");
        return 1;
    }

    dwRetVal = IcmpSendEcho2(hIcmpFile, NULL, NULL, NULL,
        ipaddr, SendData, sizeof(SendData), NULL,
        ReplyBuffer, ReplySize, 1000);
    if (dwRetVal != 0) {
        PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
        struct in_addr ReplyAddr;
        ReplyAddr.S_un.S_addr = pEchoReply->Address;
        printf("\tSent icmp message to %s\n", argv[1]);
        if (dwRetVal > 1) {
            printf("\tReceived %ld icmp message responses\n", dwRetVal);
            printf("\tInformation from the first response:\n");
        }
        else {
            printf("\tReceived %ld icmp message response\n", dwRetVal);
            printf("\tInformation from this response:\n");
        }
        printf("\t  Received from %s\n", inet_ntoa( ReplyAddr ) );
        printf("\t  Status = %ld\n",
            pEchoReply->Status);
        printf("\t  Roundtrip time = %ld milliseconds\n",
            pEchoReply->RoundTripTime);
    }
    else {
        printf("\tCall to IcmpSendEcho2 failed.\n");
        printf("\tIcmpSendEcho2 returned error: %ld\n", GetLastError() );
        return 1;
    }
    return 0;
}


"Ronny" <ronny@john.com> д����Ϣ 
news:eR7CnHqMJHA.728@TK2MSFTNGP03.phx.gbl...
>I have Windows XP and Windows Vista PC's.
> I need to use ShellExcute in my MFC application and run the dos ping 
> command with a hidden window.
> Can some gentleman here give the right syntax?
> Regards
> Ronny
> 


0
asctime (5)
10/20/2008 1:28:09 PM
Why ShellExecute?  Why not CreateProcess?

//----------------
// in stdafx.h
#define _WIN32_IE 0x500
#include <shlobj.h>
//-----------------
CString path;
LPTSTR p = path.GetBuffer(MAX_PATH);
HRESULT hr = ::SHGetFolderPath(CSIDL_SYSTEM, NULL, SHGFP_TYPE_CURRENT, p);
if(SUCCEEDED(hr))
   { /* succeeded */
    PathAppend(p, _T("ping.exe");
    STARTUPINFO info = {sizeof(STARTUPINFO)};
    PROCESS_INFORMATION processinfo;
    if(!CreateProcess(NULL, p. NULL, NULL, FALSE, 
                                   CREATE_NO_WINDOW, // or other flags
                                  NULL, NULL, &startup, &processinfo ))
      { /* CreateProcess failed */
       path.ReleaseBuffer();
       ... deal with error
     } /* CreateProcess failed */
   else
     { /* CreateProcess succeeded */
      path.ReleaseBuffer();
      ::CloseHandle(processinfo.hProcess);
      ::CloseHandle(processinfo.hThread);
     } /* CreateProcess succeeded */
   } /* succeeded */
else
   { /* failed */
    path.ReleaseBuffer();
    ...failure code here
   } /* failed */
On Mon, 20 Oct 2008 12:21:17 +0200, "Ronny" <ronny@john.com> wrote:

>I have Windows XP and Windows Vista PC's.
>I need to use ShellExcute in my MFC application and run the dos ping command 
>with a hidden window.
>Can some gentleman here give the right syntax?
>Regards
>Ronny 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/20/2008 1:41:22 PM
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:542pf49afidsrlk5avhlh80s492a24010e@4ax.com...
>    STARTUPINFO info = {sizeof(STARTUPINFO)};
>    PROCESS_INFORMATION processinfo;
>    if(!CreateProcess(NULL, p. NULL, NULL, FALSE,
>                                   CREATE_NO_WINDOW, // or other flags
>                                  NULL, NULL, &startup, &processinfo ))

Since the console window should not be visible, you need to set the 
appropriate "show window" flags in the startup info.

-- David

0
dc2983 (3206)
10/23/2008 4:32:52 AM
Reply:

Similar Artilces:

SHGetFolderPath() returns wrong folder path?
Hi all, I'd like to get the local app-data directory on my Windows XP (Brazilian Portuguese version). I tried the following code: ::SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, pszPath)); But this function returns the following (incorrect) path: C:\Documents and Settings\admin\Configura=C3=A7=C3=B5es locais\Dados de aplicativos which should have been: C:\Documents and Settings\admin\Configura=E7=F5es locais\Dados de aplicativos Any idea what the problem is? Thanks. diandaolly wrote: > Hi all, > > I'd like to get the local app-data directory on my Windows X...

Using Relative path for XML data file?
Is there a way to specify a relative path to an XML data file imported into Excel 2003? I am writing a web app that generates report data as XML for the user to download to their local machine. This data is to be consumed by an Excel reporting spreadsheet, which contains display-formatted tables and charts that are mapped to various data fields in an XML Map, which is in turn linked to the xml data file they will download. The idea is the user only needs to download the data for updates, not the whole spreadsheet. However, since I cannot predict the path where the user will store their...

Out of memory or system resources?
I am running a single MS Exchange 2000 Enterprise server, It is a duall PIII 1000Ghz processor box with 1GB Ram, and lots of disk space left. I have several users that have a large size mailbox (unable to do much about this). Lately when some users sync their mailbox with a local copy, it generates the error "Task 'Microsoft Exchange Server' reported error (0x8007000E) : 'Out of memory or system resources. Close some windows or programs and try again.'" I have this server patched up, and it does do a defrag each night. Any ideas and or tips I could try to get aro...

Migrate emails from Unix based mail systems to exchange
Hi everybody i have a question, i'm interested in knowing is it possible to move all mails from a unix / linux based mail server such as postfix or sendmail to exchange. also is there is any possibility of moving mails from other mail clients such as netscape or thunderbird or any other mail client to outlook so that i can eventially move them to exchange. any guides or documents will be much appertiated. thanks in advance -- Yours truly, Mohammed A. Raslan MCSE+I NT4, MCSA: Security, MCSE: Security, MCDBA, CCNA Mohammed, I don't think you can do that. Public RFC's are ...

What's the rootname appearing in System Manager
Hello, I am looking at a SBS server in a domain called "whatever.nl", with a computername "win2003". When I open the System Manager, the top element is called "MAILSERVER (Exchange)". Is this a default name, or something chosen during installation of Exchange? Also, when I open Server Management, under advanced management there's a node for the Exchange System Manager, however the name is "First Organization (Exchange)". When I highlight it, the name changes to "MAILSERVER (Exchange)". Is that normal? -M Hi, the name of the to...

System settings and Reports Error
Hi all another victim of this common error Here... When going into either system settings or reports we get an error saying "an error has occured please contact your system administrator" I have seen a number of posts on this but no one seems to have fixed it can anyone help. This a brand new install of crm V3.0 with sql 2000 on the same box Aidan, Can you access the basic SRS reports at http://<servername>/Reports? If not, you have an SRS issue, not a CRM double hop authentication issue, and you will need to troubleshoot your SRS install. A good document to get is...

Exchange 2003
I am encountering an error in the SM application, that there is limited info about. As I navigate to the Administrative Group, and try to view the First Storage Group, an error is displayed "An unknown error has occurred. ID no: 80040d1b". All information I can find says that the MSSearch GatherLogs are not in the place that the registry says they are, which is not the case. This is the only reference I can find to this error, and I need help because I cannot view any Information Store, public or private. This is Exchange 2003 standard, basic installation..nothing special. Any ...

insufficient system resources
I am running a Win 2003 SBS and last week started having 2of10 XP Pro clients getting a fault " insufficient system resources exist to complete the requested service" when trying to save back an opened Excel file to a shared folder. It is happening very random. If the client waits and tries later he is able to do it or if he reboots he can do it instantly. When the problem exists, he can bring up the shared folder but when trying to open any file in the folder gets the same error. Where do I start troubleshooting, is this a client issue or Server. I have looked at Eve...

Mercury Payment System Processing on Evaluation Copy
Hello, Due to some construction we are using evaluation copies of RMS until construction is completed to go to full versions. I have MPS credit card swiping that is working on my full versions already setup but the evaluation copy credit card swipes are not showing up. Does anybody know if this is due to the evaluation copy and/or possibly MPS does not allow sharing of one account? Thank you, Roger Have you settled the EDC Batch from SO Manager --> Utilities menu --> Settle EDC? Rob "Roger Neth" wrote: > Hello, Due to some construction we are using evaluation copie...

multi-user system
Hello Vista is a multi-user system. My PC is used by me, my wife, children, etc etc, we all have out own logon ids & passwords. I am the only Administrator. My son downloads a useful program from the www. He wants me & everyone else to use it. He has a shortcut to the program on his desktop. How does he, or I, copy the shortcut to the other users of my pc ? Thanks KK KRK wrote: > Hello > > Vista is a multi-user system. My PC is used by me, my wife, children, > etc etc, we all have out own logon ids & passwords. I am the only > Ad...

server system drive rights
Hi, What are the default NTFS rights on the C system drive on a windows 2003 server? I have IIS and sharepoint installed. Thank you, T Should be real similar. http://support.microsoft.com/kb/244600 -- Regards, Dave Patrick ....Please no email replies - reply in newsgroup. Microsoft Certified Professional Microsoft MVP [Windows] http://www.microsoft.com/protect "Tester" wrote: > Hi, > What are the default NTFS rights on the C system drive on a windows > 2003 server? I have IIS and sharepoint installed. > Thank you, T ...

How to replace two system files?
I have an XP machine. Have just replaced a couple files from a W7 machine. The files are:- c:\windows\system32\drivers\disk.sys c:\windows\system32\drivers\partmgr.sys ....and now I can't boot the XP machine. How to get back to before I replaced the files? Thanks. "John Smith" <JohnSmith@nospam.com> wrote in message news:uLL8mqL0KHA.264@TK2MSFTNGP05.phx.gbl... > I have an XP machine. Have just replaced a couple files from a W7 machine. > The files are:- > c:\windows\system32\drivers\disk.sys > c:\windows\system32\drivers\partmgr.sys > ....

Protecting Application by System Password.
Hi All, How I can Protect my Mfc application by asking for Admin Password/ Username if he is running it in admin mode or password of standard user if he is running it in Standard user? Is there any API to do this? Any Samples will be of great Help. Thanks in Advance. Prash ...

Exchange System Manger
I am running Exchange 2003 SP1. I run ESM, navigate to Administrative Groups, and to the administrative group, then select my exchange server, then to the First Storage Group, then to one of my 3 mail stores. I right click on the mail store, and select "Create Full-Text Index". I am getting the error: Exchange System Manger The system cannot find the path specified. Facility: MSSearch.Admin.1 ID no: 80070003 Exchange System Manger I have verified that the pathname I am specifying is valid. I tried to use the default path that is specified, and it the error still occurs. Th...

Moving the system attendant mailbox
Hello all, I am currently seperating out my mailstore databses. I am doing this because of the db totals about 150 gig. I want to dump the default store for a few reasons but one being that anyone in this store cannot do an active sync (no problems in other stores) and I have seen jet engine errors in the eventvwr. So I know it's only a matter of time. So anyways, I am almost done moving my users to the others stores, I just need to prepare to dump the default priv1.edb. I am running windows 03, exchange 03 sp2. I have read that all I have to do in 03 is simply delete the store and ...

the system administrator has set policies to prevent this installation
When I try to install Office 2000 disk 2 I get the above message. I'm signed on as Administrator, I've set all the policies, I can install any other program (including disk 1), and I've tried setting up another user with administrator priveledges. I'm using W2k, svc pack 4. Any help would be greatly appreciated. Ed As in the Office newsgroup. -- As in Publisher "���MS�Publisher���" <donotknock@nobodyhome.com> wrote in message news:#0Grj553DHA.1752@tk2msftngp13.phx.gbl... > As in the Office newsgroup. > > -- > > ...

Adding file path to worksheet footer
An icon allows for the addition of the file name to a worksheet footer. How can the path for the file name be added to the footer? David If using XL2002, there are icons in Headers/Footers Custom section for Path and Filename. If you are not using XL2002 you have to use a macro to do this. Sub PathInFooter() ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName End Sub The same code could be placed into a Workbook_BeforePrint routine. If unfamiliar with macros visit David McRitchie's website for basics. http://www.mvps.org/dmcritchie/excel/getstarted.htm Gord Dibben Ex...

Can a particular event be excluded from system event log?
I'm running XP Pro SP3 and my system log is difficult to monitor because it's overwhelmed by hundreds of innocuous information events, all with the same event number. Is there a way of preventing these particular events from appearing in the log, short of filtering out all information type events? The PC is an HP DC6005 MT with integrated ATI Radeon HD 4200 graphics. Offending event details are: Source - ati2mtag; Category - DVD-OV; ID - 62464; User- N/A; Description - UVD Information. The events are associated with video rendering and can be suppressed by modifying...

CRM crashed after changing the System Administrator
Hi, I am having CRM 1.2 installed on a Windows Server 2003 SP1 machine. I had two users in the CRM, one a System Administrator and another a CEO-Sales. Whenever I logged-in the user displayed was the System Administrator. I could log-in as the CEO-Sales. So I assigned the role of system administrator to the other user and restarted CRM. On restarting, CRM displayed error message "Invalid License for current user". I checked the help documents of CRM where I found out that what I had done was irreversible. I have uninstalled CRM. Can anyone please tell me how to log...

Transaction log and System path location
Is possible to change the location path of the system and Transaction log to another hard drive on the same server. I need to free diskspace on my c drive i want to move them to my e drive which is larger in size. Transactio n log paths are exposed in the Storage Group properties. Paul "fanman36" <fanman36@discussions.microsoft.com> wrote in message news:329F0E0B-7CB2-447C-BF40-0CD6A32D84F2@microsoft.com... > Is possible to change the location path of the system and Transaction log > to > another hard drive on the same server. I need to free diskspace on my c &g...

System.XML Migration
Hi there, I was trying to convert the following VB6 code to VB.NET. But I can't find a corresponding System.XML object for MSXML IXMLDOMSelection. I am thinking to use System.XML XMLNodeList object and GetElementsByTagName method to find the "selection". Any suggestion/comment? Thanks in advance. Abel Example: --------------------------------------------------------------- Dim xmlStatic As New MSXML2.DOMDocument xmlStatic.loadXML (strXMLString) Dim objSelection As IXMLDOMSelection Set objSelection = xmlStatic.selectNodes("//Reading") Fo...

Erroneous "New Email" display in system tray.
I am using Outlook Express version 6. The problem I'm havnig is when I open the program, it will always tell me I have multiple new emails when there are actually none. Anyone know what causes this? Is there an update or patch I need to install? Thanks. Ask in an Outlook Express group - this group support Outlook from Microsoft Office. Outlook Express belongs to Internet Explorer. You can also check http://www.tomsterdam.com for assistance with Outlook Express questions. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (i...

System Attendant Error in Application Log (Exchange 2000 + Windows 2000)
I am posting this in the hope that someone will be able to assist me with this issue. I have two Exchange 2000 servers (SP3) running in a Windows 2000 Server (SP4) Active Directory environment. I have seen that I get the following error message logged in the 'Application Log' on the Exchange server by the System Attendant: Source: MSExchangeSA Event ID: 9153 Microsoft Exchange System Attendant reported an error '0x80005000' when setting DS notification I have configured the Exchange server as a Global Catalog server, but the Excchange System Manager console does not ...

Download files from 3.5 disk in excel but system said disk need fo
...

System events question
Hi, How can I detect when user locks/unlocks computer (ctrl + alt + del then "Lock Computer" in win 2000/NT) and act on it in my app? Is there a system event that notifies that action and how do I go about using it? Thanks a lot, Alex You could get a hook into the KB and just monitor for that keypress or detect when the screensaver that locks the computer becomes active. ms-help://MS.MSDNQTR.2003APR.1033/dnwui/html/msdn_hooks32.htm "alex" <aleks79@yahoo.com> wrote in message news:ORReFobXDHA.536@TK2MSFTNGP10.phx.gbl... > Hi, > > How can I detect when ...