473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Question about Windows Registry

BLUF: I need to build up the actual %TEMP% path for all users
methodically using values in the registry, and I need to do this both
by the current user AND as a service will do this running as "Local
System." Thus, I can't rely on it always being ...\<Username>\Local
Settings\Temp.
So, this partially applies to C#, because I'll need to do this in C#
code. But, I think I already know how to do it. What I don't know is
where to find the information in the registry.

I have a service running as Local System, and I need to find each
user's %TEMP% directory. I've found a location in the registry that
is helpful, but not exactly what I am looking for. So, any help is
greatly appreciated.

I need this information, because I need the service to write something
to a particular user's directory, and as evidenced by MSFT's Virtual
PC Images, this is not always how a machine in set up (the user is
`IETester` but the %TEMP% dir is `C:\DOCUME~1\IETest\Local Settings
\Temp" (notice `IETest` instead of `IETester`).

The locations that I found in the registry are:

HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer
\Shell Folders

HKEY_USERS\S-1-...\Software\Microsoft\Windows\CurrentVersion\Expl orer
\Shell Folders

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer
\DocFolderPaths
Obviously, the CURRENT_USER is useless, because the service (running
as Local System) won't know the current user (and I need all users
anyway). If I use the value in USERS, I'll have to backtrace and find
the value of %USERPROFILE% somewhere. The LOCAL_MACHINE looks like a
reasonable place, but I don't know if it is exactly what I'm looking
for. Another problem with LOCAL_MACHINE (at least, with the registry
key I'm referencing above), is that the "Value" listed is still not
the user name for the current user. (Ex: Value is `IETest` and the
value's data is set to `C:\Documents and Settings\IETest\My
Documents`. However, the actual USER NAME is `IETester`.

Sidenote: System.IO.GetTempPath() returns the value "C:\Documents and
Settings\IETest\Local Settings\Temp," so that at least jives with what
I'm seeing in the registry (instead of relying on the actual username
to hardcode paths), but I still can't put everything together.
What is the best way to do this? I'm not sure which values in the
registry get changed if the user changes the default setting/location,
so I don't know exactly where to look. And one last question: Is this
location/forumlation the same between XP and Vista (ignoring the
Wow6432Node)?

Any help/insite is greatly appreciated!
Jun 27 '08 #1
3 1632
On Mon, 16 Jun 2008 20:55:46 -0700, thephatp <ch***********@gmail.com>
wrote:
[...]
Obviously, the CURRENT_USER is useless, because the service (running
as Local System) won't know the current user (and I need all users
anyway). If I use the value in USERS, I'll have to backtrace and find
the value of %USERPROFILE% somewhere.
Well, for better or worse, that's what you have to do. The "HKEY_USERS"
sub-keys are the ones that are per-user. If you want per-user
information, you need to inspect that part of the registry.

Pete
Jun 27 '08 #2
On Jun 17, 12:44*am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Mon, 16 Jun 2008 20:55:46 -0700, thephatp <chad.a.mor...@gmail.com*
wrote:
[...]
Obviously, the CURRENT_USER is useless, because the service (running
as Local System) won't know the current user (and I need all users
anyway). *If I use the value in USERS, I'll have to backtrace and find
the value of %USERPROFILE% somewhere.

Well, for better or worse, that's what you have to do. *The "HKEY_USERS"*
sub-keys are the ones that are per-user. *If you want per-user *
information, you need to inspect that part of the registry.

Pete
I was hoping that wouldn't be the answer. D'oh. So, if I have to do
that, where can I find the value of %USERPROFILE%?

Thanks!
Jun 27 '08 #3
On Tue, 17 Jun 2008 05:29:58 -0700, thephatp <ch***********@gmail.com>
wrote:
I was hoping that wouldn't be the answer. D'oh. So, if I have to do
that, where can I find the value of %USERPROFILE%?
I don't recall the details. You should find a newsgroup more specific to
unmanaged Windows API programming. However, I do have a vague memory that
there's a section in the HKEY_USER section for the user themselves that
contains the value for that variable.

You may find the easiest thing is to just create a brand new user, and
snoop around in the registry for that user to see what you find. Even a
brand new user will have lots of stuff in there, but at least that should
help minimize the extraneous stuff.

Pete
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Geo | last post by:
Hi to all, How can I create a registry key that can be deleted by any user on the machine. A sample code or any other reference will be greatly appreciated. Thanks, Geo
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
4
by: Steven | last post by:
I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions. I have created a category named Exceptions with the following: <category...
2
by: Abby | last post by:
I'm sorry that I post this question in this newsgroup, but I don't know where is the right place to post. I have a question if I can get to CPU's registry to modify its clock cycle so that I can...
8
by: Scott Schluer | last post by:
Hello, I'm fairly experience with VB.NET in so far as it's syntax is concerned, however I'm coming from a web-based environment. Typically, when I want to store data (i.e. user preferences,...
4
by: Alan | last post by:
dear all, I saw a program using VB.NET can auto-startup/ execute after logon the Windows. However, the program is not run as the startup menu? what function can vb.net detect the logon...
1
by: Jeremy S. | last post by:
..NET's code Access Security enables administrators to restrict the types of things that a .NET application can do on a local computer. For example, a ..NET Windows Forms application can be...
11
by: Roy | last post by:
Does anybody have any idea why 2 identical classic asp pages, hitting the same Oracle schema, but deployed on 2 different servers will render the registered trade mark differently? Example: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.