none
change desktop bat file icon

    Question

  • Hi, my C# 4.0 app runs only when a user drags a pathname to my desktop icon, then closes when processing is complete.   If I use a desktop BAT file then the dragged pathname is captured as the "%1" argument.  Is there any way to select a custom icon for a desktop BAT file in Windows 7 x64?    Is there any way to start a process with the captured dragged in pathname argument other than using a BAT file, for instance somehow with a shortcut?

     

    Saturday, June 05, 2010 12:49 AM

All replies

  • Bat and lnk files are handled differently. Bat files are opened as %1 %* so all arguments will be passed to the bat file.

    I cannot find a placeholder you can specify an command line argument placeholder in lnk file's default handler IShellLink. You can try write a shell content menu extension that pass the command line arguments and invoke the default handler if there is no argument.

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Saturday, June 05, 2010 1:49 PM
    Moderator
  • Hi, Do you mean "shell context menu extension"?    Is there anywhere I can find an example of hooking IShellLink in C#? 
    Sunday, June 06, 2010 3:46 PM
  • No, I mean changing the associated opener of the shortcut file type.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Sunday, June 06, 2010 3:59 PM
    Moderator
  • Hello

    Thank you for the suggestions! I may be missing something here. It appears to me that it is not necessary to change the associated opener of the shortcut file type. Here is my experiment.

    1. I created a simple console application that prints the received arguments:

    int wmain(int argc, wchar_t *argv[])
    {
        for (int i = 0; i < argc; i++)
        {
            wprintf(L"%s\n", argv[i]);
        }

        getwchar();
        return 0;
    }

    2. I created a shortcut link of the above exe and put the shortcut link on the desktop.

    3. I dragged and dropped a file (of any file type) to the shortcut link on the desktop. The application is started, and the path of the dragged file is printed in the console.


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, June 07, 2010 5:41 AM
    Moderator
  • Hello

    How are you? May I know the status of the issue?


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, June 14, 2010 9:55 AM
    Moderator