User home dir windows

What is the alternative for

I’m trying to use the command prompt to move some files, I am used to the linux terminal where I use

to specify the my home directory I’ve looked everywhere but I couldn’t seem to find it for windows command prompt ( Documents and Settings\[user] )

11 Answers 11

You’re going to be disappointed: %userprofile%

You can use other terminals, though. Powershell, which I believe you can get on XP and later (and comes preinstalled with Win7), allows you to use

for home directory.

You can %HOMEDRIVE%%HOMEPATH% for the drive + \docs settings\username or \users\username .

You can use %systemdrive%%homepath% environment variable to accomplish this.

The two command variables when concatenated gives you the desired user’s home directory path as below:

Running echo %systemdrive% on command prompt gives:

Running echo %homepath% on command prompt gives:

When used together it becomes:

Update — better version 18th July 2019.

Final summary, even though I’ve moved on to powershell for most windows console work anyway, but I decided to wrap this old cmd issue up, I had to get on a cmd console today, and the lack of this feature really struck me. This one finally works with spaces as well, where my previous answer would fail.

In addition, this one now is also able to use

as a prefix for other home sub-folders too, and it swaps forward-slashes to back-slashes as well. So here it is;

Step 1. Create these doskey macros, somewhere they get picked up every time cmd starts up.

Step 2. Create the cdtilde.bat file and put it somewhere in your PATH

Tested fine with;

Oh, also it allows lazy quoting, which I found useful, even when spaces are in the folder path names, since it wraps all of the arguments as if it was one long string. Which means just an initial quote also works, or completely without quotes also works.

All other stuff below may be ignored now, it is left for historical reasons — so I dont make the same mistakes again

old update 19th Oct 2018.
In case anyone else tried my approach, my original answer below didn’t handle spaces, eg, the following failed.

Читайте также:  Bios setup utility настройка для восстановления windows

I think there must be a way to solve that. Will post again if I can improve my answer. (see above, I finally got it all working the way I wanted it to.)

My Original Answer, still needed work. 7th Oct 2018.
I was just trying to do it today, and I think I got it, this is what I think works well;

First, some doskey macros;

Where is /home directory on windows? [duplicate]

How do you find ubuntu’s home directory on windows? I’ve tried searching through windows file explorer by typing ubuntu/home nothing shows up. Does anybody have any suggestions? Thanks for all your help in advance.

4 Answers 4

The equivalent of Ubuntu’s

/ (a.k.a. /home/yourusername/ ) in Windows 10 is C:\Users\yourusername\ .

The equivalent is C:\Users\

So for you, your home directory would be here:

Windows can’t read Linux partitions. That is why you couldn’t find the home directory of Ubuntu.

Instead, you could install third-party softwares to do that, like Ext2Fsd, DiskInternals Linux Reader and so on.

I believe I can safely assume that there is no /home directory on Windows. It probably depends on which Windows OS you are talking about. I think Windows XP, Windows Vista, and Windows 7 has a /home directory, however. In case I am wrong (I probably am) I suggest waiting for another answer.

Not the answer you’re looking for? Browse other questions tagged home-directory or ask your own question.

Linked

Hot Network Questions

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

How do I change the default location for a users home directory in Vista?

I would like to move the default location of my c:\Users\USERNAME to another drive. What is the easiest way to do this and how?

I know that I can move each of my «Special Folders» like Documents, Pictures, etc. but that does not include the AppData folder. Also, many programs and installers incorrectly put stuff in C:\Users\USERNAME\Documents etc. even after I moved Documents to another drive and I end up with duplicate folders.

5 Answers 5

For individual folders (My Docyuments, My Pictures, etc., the «Special Folders») I do the registry/GPO thing you alluded to. However, if I want to move the entire folder structure I cheat. Move the folder to a new location, and then create a junction pointing the old folder to the new folder. So all your programs will still think the folder is c:\users\username but that’s just a junction point to d:\users\username .

Читайте также:  Панель поиска windows недоступна ms outlook 2010

I’ve spent a long time researching this and finally managed to do it on my own machine.

There are two scenarios here: a new install, and a machine that is already installed/used.

For a new install, you can (apparently) modify the autounattend.xml file (unresearched link here, no guarantees, I haven’t tried)

For a machine that is already installed, there are two problems to overcome:

  1. Windows ‘locking’ some files, so you can’t copy them (ntuser.dat)
  2. Changing where windows goes to look for the profiles on startup.

For problem 1, you can either go the round about route:

  • copy Default and Public folders to the new location
  • modify their location in registry
  • create a new user (which will be created in the new location)
  • login with new user account and copy the other users
  • lots of detail on this here

Or you can boot from a Recovery disk and copy stuff across.

For problem 2, you can either do a find and replace everywhere in the registry (risky), or create a symlink/junction from the default location to the new location.

The find and replace solution is also detailed on the previously linked page, but it turns out that you still have to create the symlink, otherwise Windows Update has problems.

WHATEVER you choose to do, you will need to get familiar with symlinks/junctions. Lots of comments on Josh’s blog mention ROBOCOPY, which you can’t use to copy Junctions. If you don’t recreate them, you won’t notice immediately as most (if not all) have the hidden attribute anyway, but you may experience reverse compatibility problems with non-Vista apps.

This blog post provides a bit more (too much) detail about this issue, plus a script to help recreating the symlinks/junctions.

How to find the real user home directory using python?

I see that if we change the HOME(linux) or USERPROFILE(windows) environmental variable and run a python script, it returns the new value as the user home when I tried, os.environ[‘HOME’] os.exp

Is there any way to find the real user home directory without relying on the environmental variable?

edit:
Here is a way to find userhome in windows by reading in the registry,
http://mail.python.org/pipermail/python-win32/2008-January/006677.html

edit:
One way to find windows home using pywin32,

user It takes you to home directory of current user. On windows have no idea. – mAm Apr 19 ’10 at 16:06

9 Answers 9

On Unix and Windows, return the argument with an initial component of

user replaced by that user‘s home directory.

On Unix, an initial

Читайте также:  Флешка с линуксом не отображается

is replaced by the environment variable HOME if it is set; otherwise the current user’s home directory is looked up in the password directory through the built-in module pwd . An initial

user is looked up directly in the password directory.

On Windows, HOME and USERPROFILE will be used if set, otherwise a combination of HOMEPATH and HOMEDRIVE will be used. An initial

user is handled by stripping the last directory component from the created user path derived above.

If the expansion fails or if the path does not begin with a tilde, the path is returned unchanged.

How to change HOME directory and start directory on MSYS2?

I have installed MinGW-w64 and MSYS2. But how do I change the HOME directory in MSYS2? So that when I type cd $home or cd

it goes to another directory that I defined.

And how do I write a code so that the starting directory is always where the .bat file is placed on?

In cmd I used this code:

so when I open cmd on my desktop, it starts from the directory on desktop.

How can I do a similar thing with msys2?

6 Answers 6

If you would like to use your windows home folder as the home folder for MSYS2, you can edit /etc/nsswitch.conf and write:

Msys2 will use windows %HOME% as it’s $HOME dir. If you set %HOME% in environment variables (to the windows directory you need Msys2 to use) it will work.

In one of your shell startup scripts (e.g.

is the default/original home directory) you can change the $HOME environment variable:

If you want your shell to open in that directory you might need to run cd (with no arguments) after setting $HOME ; I have not tested it.

Create or modify an MSYS2 /etc/passwd file. Two ways of doing this are shown below.

The following command can be run from an MSYS2 shell, and works safely whether or not the file exists and whether or not it already contains the current user:

Next, edit /etc/passwd , and change the relevant user’s home directory field (the 6th colon-delimited field).

BONUS: It is also possible to change the MSYS2 username by editing the first field.

As desired, move current home directory content to the new home directory.

Log off, then log back in.

The /etc/passwd edits can be done without manual editing, but this makes for a more complex command-line to paste into the MSYS2 shell, and, it might not work if the /etc/passwd file already exists and has the username in it already:

Оцените статью