CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    Vista Explorer.exe problem

    this works fine in any version of windows all the way up to XP..
    It will not work in vista, is just opens the "users" folder and selects nothing.

    Code:
    //open and select the file in windows explorer
    //more info about this at http://support.microsoft.com/default...;EN-US;q152457
    CString sFile = "C:\\test.txt";
    CString s;
    s.Format("/select,\"%s\"",sFile);
    ShellExecute(NULL,_T("Open"),_T("Explorer"),s,NULL,SW_SHOWDEFAULT);

    Does anyone know how to make this work in vista?
    I have looked through MSDN and found nothing

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Vista Explorer.exe problem

    Could be UAP getting invoked...try it with a target in the documents folder. (The average user should NOT have access to the root of the drive!)
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    Re: Vista Explorer.exe problem

    I have UAP disabled

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Vista Explorer.exe problem

    Did you TRY a file in the Documents ddirectory?
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Feb 2007
    Location
    Craiova, Romania
    Posts
    326

    Re: Vista Explorer.exe problem

    Quote Originally Posted by 12oclocker View Post
    I have UAP disabled
    yes, but user permissions are still in effect. try saving in different folder, as suggested before.
    by the way, I believe it is UAC (User Account Control)

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Vista Explorer.exe problem

    You are correct....is it UAC....I have just been making soo many posts about AUP (A totally different subject) that I had a case of happy fingers)
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  7. #7
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    Re: Vista Explorer.exe problem

    lol, I knew what you ment about UAC, I disabled all the junk, lol
    yes, it still will not work in the documents directory, it works fine when I try it from a command line.... It IS executing Explorer.exe, but its NOT passing the "lpParameters" I have defined.
    I know the lpParameters are correct, because it works perfect in XP, and even in Vista from a command line.
    For some reason it seems Vista is Ignoring ShellExecute's lpParameters

  8. #8
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    Re: Vista Explorer.exe problem

    so this is what I am forced to do right now, because vista I guess sucks....

    Code:
    OSVERSIONINFO osv;	
    osv.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
    ::GetVersionEx(&osv);
    if(osv.dwPlatformId == VER_PLATFORM_WIN32_NT && osv.dwMajorVersion >= 6)//Windows Vista
    {
    	ShellExecute(NULL,_T("open"),GetParentDir(sFile),NULL,NULL,SW_SHOWDEFAULT);
    }
    else //WinXP, 2K, etc
    {
    	CString s;
    	s.Format("/n,/select,%s",sFile);
    	ShellExecute(NULL,_T("open"),_T("explorer.exe"),s,_T("%SystemRoot%"),SW_SHOWDEFAULT);
    }
    So now I can open the folder with the file in it, BUT I cannot have the file selected as I can in windows XP, because VISTA is Ignoring my Params for "explorer.exe"

    anyone have any ideas??

  9. #9
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Vista Explorer.exe problem

    Are you SURE it did not work, if you specify just "test.txt" (No PAth, just name, extension) and you have "Test.txt" in your Documents folder?????

    That SHOULD work. (And a quick test on my machine did!)

    One of the DOCUMENTED changes in explorer.exe is that it ALWAYS starts in your documents folder, and that there are restrictions.

    If you want to change your default folder for Explorer.exe there are way such as: http://blogs.msdn.com/rextang/archiv...1/8347682.aspx

    You will also note that the documentation for /select ONLY covers XP and does NOT mention Vista.... http://support.microsoft.com/default...4853#appliesto
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  10. #10
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    Re: Vista Explorer.exe problem

    "/select" does work in vista (see example D)
    http://www.vistax64.com/tutorials/71...t-opening.html

    copy and paste this into your command line....
    %SystemRoot%\explorer.exe /n, /select, C:\WINDOWS\system32\notepad.exe

    once you execute that, vista will open a new explorer window, and select "notepad.exe" and scroll it into view. that is what I am trying to get my application to do.

    it works perfect from the command line in vista, it wont work in ShellExecute, ShellExecuteEx, or WinExec, ect from my application.
    I am currently log in as administrator, and my application has be launched under my administrative privilege level.
    BUT I can call the explorer.exe process without any problems in my application, it just wont process any of the switches I send it via ShellExecute.
    So I CAN open a folder to any drive, etc. I just cant select a file in the folder because VISTA is ignoring the switches I sent to Explorer.exe via my program.

    I need my application to be able to do this no matter where the folder is located, even if it does work in the documents folder, it does not solve my problem.
    Last edited by 12oclocker; December 23rd, 2008 at 10:32 PM.

  11. #11
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Vista Explorer.exe problem

    Quote Originally Posted by 12oclocker View Post
    I need my application to be able to do this no matter where the folder is located, even if it does work in the documents folder, it does not solve my problem.
    The first step in solving any problem is to analyze the various permutations. By changing to just a filename and using the default location,it eliminates some conditions.

    Another parallel test would be to ignore explorrer, and just attempt to get the parameters through to a simple "echo" type program that will display what is being passed to it.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  12. #12
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Vista Explorer.exe problem

    The /select option works for Vista. I would suggest you to:

    - use "explore" the verb.
    - Do not specify "Explorer.exe" as File-name to open.
    - Try specifying other parameter for Explorer (other than /select).
    - Use Null as verb.

    Try the combinations, and get it solved!
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured