Hi all,
A Windows service (which obviously starts before any user logs in) is
failing to:
- read something from registry from a key under the HKCU
- try to find out the user path by doing the following call:
SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path)
if any of these is tried before a user logs in.
My question is: are these 2:
- read something from registry from a key under the HKCU
- try to find out the user path by doing the following call:
SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path)
supposed to fail also after the user logs in? (XP and 2000)
Thanks in advance,
Viv 4 5434
Hi,
I think this is because the user profile of the service account is not
loaded.
You should use LoadUserProfile and then access HKCU. SHGetFolderPath is
using HKCU as well.
Sincerely,
Kornél Hi all,
A Windows service (which obviously starts before any user logs in) is failing to: - read something from registry from a key under the HKCU - try to find out the user path by doing the following call: SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path) if any of these is tried before a user logs in.
My question is: are these 2: - read something from registry from a key under the HKCU - try to find out the user path by doing the following call: SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path) supposed to fail also after the user logs in? (XP and 2000)
Thanks in advance, Viv
Thx for your answer.
Actually I have a LSP (layered service provider) dll that is loaded by
all services and I noticed that for services, in my dll trying to read
the HKCU fails, and wasn't sure if this is a general rule for all
services or the behaviour depends on how the service is written ...
Seems that it can be different depends if the service is doing a
LoadUserProfile () call before my dll is used right?
Thanks,
Viv
On Fri, 11 Mar 2005 20:10:44 +0100, "Kornél Pál"
<an*******@disc ussions.microso ft.com> wrote : Hi,
I think this is because the user profile of the service account is not loaded. You should use LoadUserProfile and then access HKCU. SHGetFolderPath is using HKCU as well.
Sincerely, Kornél
Hi all,
A Windows service (which obviously starts before any user logs in) is failing to: - read something from registry from a key under the HKCU - try to find out the user path by doing the following call: SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path) if any of these is tried before a user logs in.
My question is: are these 2: - read something from registry from a key under the HKCU - try to find out the user path by doing the following call: SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path) supposed to fail also after the user logs in? (XP and 2000)
Thanks in advance, Viv
"Viviana Vc" <vc*******@hotm ail.com> wrote in message
news:39******** *****@individua l.net... Thx for your answer.
Actually I have a LSP (layered service provider) dll that is loaded by all services and I noticed that for services, in my dll trying to read the HKCU fails, and wasn't sure if this is a general rule for all services or the behaviour depends on how the service is written ... Seems that it can be different depends if the service is doing a LoadUserProfile () call before my dll is used right?
Sure "environmen t" depends on what is done before your code is run. :)
The default account used for Services ("LocalSyste m") simply doens't
have a user profile so no HKCU link is created to a new place in
HKU. (I'm not fully sure but the HKCU may be linked to HKU\.DEFAULT
by default).
So either you load an suitable profile for LocalSystem (making sure the
local account can access the file), define a normal account as the service
account or, most properly, use keys somewhere under HKLM or most
properly HKLM\SYSTEM\Cur rentControlSet\ Services\MyServ ice\Parameters
- Sten
Thanks, Viv
On Fri, 11 Mar 2005 20:10:44 +0100, "Kornél Pál" <an*******@disc ussions.microso ft.com> wrote :
Hi,
I think this is because the user profile of the service account is not loaded. You should use LoadUserProfile and then access HKCU. SHGetFolderPath is using HKCU as well.
Sincerely, Kornél
Hi all,
A Windows service (which obviously starts before any user logs in) is failing to: - read something from registry from a key under the HKCU - try to find out the user path by doing the following call: SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path) if any of these is tried before a user logs in.
My question is: are these 2: - read something from registry from a key under the HKCU - try to find out the user path by doing the following call: SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURR ENT, path) supposed to fail also after the user logs in? (XP and 2000)
Thanks in advance, Viv
> "Viviana Vc": Actually I have a LSP (layered service provider) dll that is loaded by all services and I noticed that for services, in my dll trying to read the HKCU fails, and wasn't sure if this is a general rule for all services or the behaviour depends on how the service is written ... Seems that it can be different depends if the service is doing a LoadUserProfile () call before my dll is used right?
After the answer of Arnaud Debaene I have done some test using the following
environment:
Windows XP SP2, Microsoft .NET Framework 1.1 SP1, a test service written in
C#
I have tried the service with Local System, Local Service, Network Service
and a custom, non-administrative user.
In all of these cases I was able to access HKCU for read and write as well.
And I'm sure that the Framework isn't using LoadUserProfile at all.
"Sten Westerback": Sure "environmen t" depends on what is done before your code is run. :)
The default account used for Services ("LocalSyste m") simply doens't have a user profile so no HKCU link is created to a new place in HKU. (I'm not fully sure but the HKCU may be linked to HKU\.DEFAULT by default).
So either you load an suitable profile for LocalSystem (making sure the local account can access the file), define a normal account as the service account or, most properly, use keys somewhere under HKLM or most properly HKLM\SYSTEM\Cur rentControlSet\ Services\MyServ ice\Parameters
The Local System account has a HKCU key and it is the same as
HKEY_USERS\.DEF AULT.
For more information please read my reply to Arnaud Debaene's message.
According to Platform SDK Documentation LoadUserProfile can be called only
by administrators or system. It is intendet to be used by a service if you
are using a high privileged account (eg. Local System) and want to
impersonate to a low privileged account. In this case the profile of the
impersonated account is not loaded and you have to load it using
LoadUserProfile to access HKCU for example. But you have to load it as Local
System.
I'm sure if a service is executed it has a HKCU. You problem may be caused
because the underlaying service is doing impersonation without loading the
user profile. But I cannot tell you anything else wthout the analisis of the
wole soultion...
I advise you the same as Sten to use a registry key in HKLM, the mentioned
Parametes subkey is a common solution.
Sincerely,
Kornél This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Wiktor Zychla |
last post by:
I need a patch that is returned by API's SHGetFolderPath with
CSIDL_COMMON_DOCUMENTS. I expected to find it among other enums in
Environment.SpecialFolder enumeration. But I cannot find it there.
Do I really have to PInvoke SHGetFolderPath in this case? Why someone forgot
about this one CSIDL? Is it just an annoying omission or there is a deeper
reason for this?
what's more: there's a mistake in a MSDN doc. it says:...
|
by: Clint |
last post by:
Hey all -
I'm having a really confusing problem concerning a web service. Right
now, I have an application that needs to call a web service that does
nothing but return "true" (this will obviously change once the
program's fully built to actually do something, but for testing, it
works).
The only code I added to the service is below:
|
by: Primo |
last post by:
Hi,
This problem has been frustrating me for days and I hope you experts can
help me out. I am trying to run a command, which I would normally run from
the command line, from within my C# application. The command runs
successfully from a Windows Form but fails if the application is recasted as
a Windows service. The application is essentially a File Watcher that should
run the process when a file is dropped into a specific directory.
...
|
by: Adam Klobukowski |
last post by:
Hello
I've written a small C# program that uses VFPOLEDB it is working
perfectly. Then, I redesigned it to work as service (as described in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughcreatingwindowsserviceapplication.asp).
Unfortunetly, now my service is unable to use VFPOLEDB, stating that it
"is not registered" on my local machine.
Service is installed on LocalService account.
|
by: MSDN Account |
last post by:
I have looked at the documentation for 'Microsoft.Win32.Registry' and
'System.Security.Permissions.RegistryPermission' but am still stuck, hoping
some can give me a nudge in the right direction.
I would like to be able to modify the GPO Policy keys under HKCU for the
logged user from an application. Because they are read only to the user can
I prompt for an ID and PW (say a support tech) that can be used to access
the keys with...
| |
by: atx |
last post by:
Hi,
I have a web service, as I understand from msdn docs, web services in IIS 6
works with network service account. Therefore for a specific purpose, I have
to access the HKCU registry of network service account and add some keys
there. But the problem is that, How to do that, since network service
account is not a normal user account. can you please tell me how to do such
a change in reg (HKCU) of network service account??
thanks,
atx
|
by: Ahmad Jalil Qarshi |
last post by:
Hi!
I am developing an application in C# as a windows NT Service.
This application needs to check for eventlog using
EventLog.Exists("System")
But unfortunately it generates exception "Requested registry access is not
allowed."
|
by: Ahmed Perlom |
last post by:
Hi all,
I am trying to start a windows application that has a GUI from a Windows
service written in .NET 2.0. I have been searching on this for few days now
with no avail. When using the System.Diagnostic.Process object to start the
application (i.e Notepad), the new app runs and it is listed on the task
manger list, but the GUI doesn't show up in the desktop of the current user.
I am aware windows service (either LocalSystem,...
|
by: Simon Hart |
last post by:
Hi,
I am using Impersonation and turned off anon access for my web service. I am
using the administator to authenticate the request using ICredentials. I am
simply trying to read a key in HKEY_CURRENT_USER from my Web Service method
call which I am unable to. When I try and open it it returns null. Even
iterating all keys under HKEY_CURRENT_USER only returns a handful of keys.
I can happily read any key under HKEY_LOCAL_MACHINE. I have...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |