Sysinternals Homepage
Forum Home Forum Home > Windows Discussions > Development
  New Posts New Posts RSS Feed: hh.exe problem during switch user
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

hh.exe problem during switch user

 Post Reply Post Reply
Author
Message Reverse Sort Order
_chew View Drop Down
Newbie
Newbie


Joined: 01 September 2008
Online Status: Offline
Posts: 4
Post Options Post Options   Quote _chew Quote  Post ReplyReply Direct Link To This Post Topic: hh.exe problem during switch user
    Posted: 12 September 2008 at 3:21am
Let me try that. I'll post whatever findings I"ll encounter. Thanks a lot.
Back to Top
molotov View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 04 October 2006
Online Status: Offline
Posts: 17492
Post Options Post Options   Quote molotov Quote  Post ReplyReply Direct Link To This Post Posted: 12 September 2008 at 2:42am
This problem occurs only during switch user to limited account (XP only) in which Process Monitor has its capture events disabled since it requires admin privileges.
You could have Process Monitor running in another (admin) session.  It should pick up the activity resulting from a user switch, etc.  After recreating the problem, switch to the session in which Process Monitor is running, and go over the capture.


Edited by molotov - 12 September 2008 at 2:42am
Daily affirmation:
net helpmsg 4006
Back to Top
_chew View Drop Down
Newbie
Newbie


Joined: 01 September 2008
Online Status: Offline
Posts: 4
Post Options Post Options   Quote _chew Quote  Post ReplyReply Direct Link To This Post Posted: 12 September 2008 at 2:39am
Hi molotov,

This problem occurs only during switch user to limited account (XP only) in which Process Monitor has its capture events disabled since it requires admin privileges.

I think the problem is not with the .chm command line/path string since the .chm is successfully launched when logged as admin. Also, everythings seems ok in Process Monitor. I thought this has to do with access privileges. I was thinking limited account sometimes can't successfully use hh.exe. Some forums also agree on this but I think that's not really the reason since limited user can still launch the .chm file successfully (help window will appear) as long as I start from logoff -> logon. Failure only happens when I'm from admin, then switch user to limited (no logoff), then launch the .chm in limited user.

As of now, I've included this in the "known issues" section of release notes but until now, I can't seem to explain the real cause of this.
Back to Top
_chew View Drop Down
Newbie
Newbie


Joined: 01 September 2008
Online Status: Offline
Posts: 4
Post Options Post Options   Quote _chew Quote  Post ReplyReply Direct Link To This Post Posted: 12 September 2008 at 2:07am
Hi lyall

We're using the same ways. I think you need to explicitly include the path of your chm file. In my C++ syntax;

CreateProcessAsUser(hUserToken,
       NULL,
       "C:\\WINDOWS\\hh.exe \"C:\\Help\\xx.chm\"",
       NULL,
       NULL,
       FALSE,
       NORMAL_PRIORITY_CLASS,
       NULL,
       NULL,
       &si,
       &pi);

" " is important when the directory has spaces within. (i.e. Program Files)


Edited by _chew - 12 September 2008 at 2:08am
Back to Top
molotov View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 04 October 2006
Online Status: Offline
Posts: 17492
Post Options Post Options   Quote molotov Quote  Post ReplyReply Direct Link To This Post Posted: 11 September 2008 at 5:07pm
What happens when you explicitly specify the path to helpfile.chm?

Have you used Process Monitor to try to determine what is happening?  Is the command-line of the created hh.exe process what you expect it to be?  Is it encountering some problem searching for helpfile.chm?
Daily affirmation:
net helpmsg 4006
Back to Top
lyall View Drop Down
Newbie
Newbie


Joined: 11 September 2008
Online Status: Offline
Posts: 1
Post Options Post Options   Quote lyall Quote  Post ReplyReply Direct Link To This Post Posted: 11 September 2008 at 5:05pm
Hi,

I'm trying to do something similar from C# using p/invokes to the Win32 API functions.

- Windows service (C#) that launches an application.
- Application (also C#) is thus running as SYSTEM account.
- Application needs to launch a .chm help file which cannot be done from SYSTEM account.

I use WTSGetActiveConsoleSessionId() and WTSQueryUserToken() to get the primary token for the active console session.

I then use CreateProcessAsUser to execute the command line "C:\\Windows\\hh.exe helpfile.chm".

The functions all return with no errors but all that happens is, hh.exe pops up a message box saying: "Cannot open the file: helpfile.chm."

My CreateProcessAsUser is as follows:

CreateProcessAsUser(
                                    token,
                                    null,
                                    new StringBuilder("C:\\Windows\\hh.exe helpfile.chm"),
                                    ref saProcess,
                                    ref saThread,
                                    false,
                                    0,
                                    IntPtr.Zero,
                                    null,
                                    ref si,
                                    out pi)


Running "notepad.exe test.txt" works fine. Also, if the application is launched manually by the user, so that it is running under the user account naturally, it has no problem opening the help file using a straightforward CreateProcess (or the .NET equivalent).
Back to Top
molotov View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 04 October 2006
Online Status: Offline
Posts: 17492
Post Options Post Options   Quote molotov Quote  Post ReplyReply Direct Link To This Post Posted: 02 September 2008 at 4:27am
Hi _chew,
 
You could perhaps consider using Process Monitor to capture data from a scenario where launching the chm does work, and a scenario where launching the chm does not work.  You could then compare the captures and see what the differences are.
Daily affirmation:
net helpmsg 4006
Back to Top
_chew View Drop Down
Newbie
Newbie


Joined: 01 September 2008
Online Status: Offline
Posts: 4
Post Options Post Options   Quote _chew Quote  Post ReplyReply Direct Link To This Post Posted: 01 September 2008 at 11:38am
Hi there,

Anyone out there who could help me in this. So far, I can't get clearer info/docs regarding this one; I would be more than grateful...

I have an app (impersonated from a service - SYSTEM account) that uses .chm for help topics. Launching the chm file using HtmlHelp API somehow fails when you're SYSTEM account so I changed it using hh.exe, CreateProcessAsUser and WTSQueryUserToken. This works fine in both admin and limited user account during normal logon. However, during user switching, limited user can't somehow launch the chm file.

(SYSTEM account)
logon admin (from startup) -> launch chm file : ok
logon limited (from startup) -> launch chm file : ok
logon admin (from startup) -> switch user (limited) -> launch chm : nothing happens
logon limited (from startup) - switch user (admin) -> launch chm : ok

No messages/warnings from windows event logs. Also, the API's are returning nonzero (success), both WTSQueryUserToken and CreateProcessAsUser.

Though, this is not really a big issue but client is asking for explanations and I can't get straightforward docs online.

Working with XP Prof SP3 and VC++ 6.0. Only happening in XP and Server 2003. Everything works fine with Vista and Server 2008.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down