[RESOLVED] Win 7 does not open Explorer to \Users\...\AppData from VB6 code for Standard user
For some reasons Win 7 does not open Explorer to \Users\...\AppData\ from VB6 code for the Standard user.But it works fine in Windows 10 for the same Standard user!
Here is the code
Option Explicit
Private Sub Command1_Click()
Dim objShell As Object
Dim sPath As String
Dim strAppData As String
Const QUOTE As String = """"
Const ssfCOMMONAPPDATA = &H23
Const ssfLOCALAPPDATA = &H1C
Const ssfAPPDATA = &H1A
strAppData = CreateObject("Shell.Application").NameSpace(ssfLOCALAPPDATA).self.Path
sPath = strAppData
sPath = Replace(sPath, QUOTE, QUOTE & QUOTE)
Shell "explorer.exe /e" & sPath, vbNormalFocus
End Sub
Any ideas how I can open Windows explorer for the Standard user and point to \AppData\ in Windows 7 ?? :confused:
Re: Win 7 does not open Explorer to \Users\...\AppData from VB6 code for Standard use
Aren't you missing a space?
Code:
Shell "explorer.exe /e " & sPath, vbNormalFocus
I think you may be working too hard, for example:
Code:
Private Sub Command1_Click()
Const ssfLOCALAPPDATA = &H1C
CreateObject("Shell.Application").Explore ssfLOCALAPPDATA
End Sub
Of course that still doesn't answer your question. However it seems to work fine for me on both Windows 7 and Windows 10.
It really sounds like something else is going on here. What haven't you told us? For example why the repeated comments regarding "Standard user" here? I'm not sure I understand what you are getting at.
"Standard User" can have two meanings. It refers to the normal default security token of an admin User or the only security token of a non-admin ("Standard") User. I assume you mean you have at least one of each (one User defined as a member of Administrators and another not) but that shouldn't make any difference anyway.
Re: Win 7 does not open Explorer to \Users\...\AppData from VB6 code for Standard use
Hi Dilettante,
Thank you very much for your code. It works great. But while I tested your code I realized that my code also works fine. Problem was not with code itself but with testing. To test my app under Standard (i.e. non-Admin) account I started application using the "Run as different user" option (Shift + right-click)
Application started as standard user, but when I attempted to open Win Explorer application for some reasons attempted to open the AppData of the logged user (i.e. myself) and not as the user who started application.
As soon as I logged to Windows 7 as Standard user both codes (your and mine) became working.
This case shows important difference between application running by logged non-admin user and application that just starts by non-admin user using the "Run as different user" option.
In any case thank you for your valuable response!
Problem solved