HOMEPATH not defined when running cmd as administrator (Windows 7 x64)

1

The application I want to use needs the HOMEPATH environment to be set in order to work flawlessly. It's usually no problem because it's set by default. Here's the cmd dump:

C:\Users\xxxx>set home
HOMEDRIVE=C:
HOMEPATH=\Users\bert

The problem comes when I try to elevate the application's privilage to Administrator (by right-clicking -> Run as Administrator). The application can't find the HOMEPATH. SO I try to run the same command as above in a cmd window that's also elevated. Lo and behold:

C:\windows\system32>set home
Environment variable home not defined

Why? And how can I fix this? I've search all over the place with no result :(

I'm also not sure how to set the HOMEPATH per user, as I find no sufficient documentation on this, both on MSDN and the Internet.

Thanks before.

EDIT TO PROVIDE MORE CONTEXT

I have two users on my machine, one is on the Administrator Group, and one as the normal user (Users Group). For my dialy use, I run under the normal user, and for the run as administrator command, I run as the other user. That user on the Administrator Group is not "Super-Admin" which require no UAC prompt, it is the user that's created when we install windows. Is there any information I need to add?

bertzzie

Posted 2012-03-22T13:24:42.020

Reputation: 165

1

I can't replicate this: http://imgur.com/O9Nsv

– Der Hochstapler – 2012-03-22T13:35:22.507

Are you running a standard CMD? – Ƭᴇcʜιᴇ007 – 2012-03-22T13:45:41.760

Do you have the "Administrator" account enabled on your system? – Der Hochstapler – 2012-03-22T13:53:19.787

@techie007 yes, it is standard cmd. – bertzzie – 2012-03-22T13:54:30.017

@OliverSalzburg what do you mean by the Administrator account? The one that needs no UAC prompt? – bertzzie – 2012-03-22T13:54:59.313

@bertzzie There is a built-in Administrator account in Windows 7 that is disabled by default (http://technet.microsoft.com/en-us/library/dd744293(v=ws.10).aspx). I was wondering whether this might be related.

– Der Hochstapler – 2012-03-22T13:59:04.957

@OliverSalzburg Oh, that one. I do not activate that one. The admin account is the account that's created when we install windows. See the new edit. – bertzzie – 2012-03-22T14:00:36.373

Answers

2

When you 'run as Administrator' you're outside the user's context, so you may not have the user's environment variables (like HomePath) available to you.

Having said that, this isn't what I find. When I start a CMD (as Administrator), the HomePath is still the current user's Homepath.

Anyhow, to set a User's Homepath on a stand-alone Windows 7 machine navigate to Control Panel\User Accounts\User Accounts, click "Manage User Accounts", Click the Advanced Tab, click "Advanced" button.

You can also get there by clicking Start and search for "Edit local users and groups", or run "lusrmgr.msc".

Once there, double-click "Users" folder, right-click the user you want to modify, click "Properties", click the "Profile" tab.

You can set you HomePath (and other paths as well) for that user in there.

enter image description here

Ƭᴇcʜιᴇ007

Posted 2012-03-22T13:24:42.020

Reputation: 103 763

The homepath is defined by the Home folder Local path text box. This fixed my issue where a service's HOMEPATH was wrong. – JDiMatteo – 2016-06-14T16:45:57.303

I'm a little confused... Which textbox should I fill for the homepath? – bertzzie – 2012-03-22T14:01:09.553