Windows User home directory - windows

So odd situation here. in AD, we have our user's home directory set as a network drive (D:), so when you open command prompt, it starts you in D:. I need to make a script that copies a file to their desktop. I can't use %userprofile% because it will use D:. Any ideas?

I found out, I was able to use C:\users\%username%\desktop or %UserProfile%\Desktop.

Related

Unable to find files in Documents from cmd

I am using Windows 10 and when I save a document I see the Documents folder it is being saved to on the left of the screen in the list under 'thisPC'. The bottom of that list has the C: drive. From Powershell, Bash or command prompt when I try to cd or locate the file I just saved I am told that it cannot find such a file. Why is my home directory the C: and not include the other files I mainly work with? I appreciate any help. Thank you
Command prompt works with files and folders.
Explorer works with virtual files or folders. Explorer is for users to easily find their stuff.
In Command prompt there is no such thing as This PC or anything under it. These are virtual things.
dir "%userprofile%\documents"
will list the files in your Documents folder if it is in the default location.

Viewing and copying document on a laptop onto a usb only using command prompt

I am trying to download a file onto a usb from my laptop which is suffering from software issues. I used the command C:users\username>\dir documents on another pc, and was able to view the documents in the folder however, on the laptop in question, the command did not work and I was given the message "The system cannot find the path specified." I am trying to find the name of the document I need to copy so I am requesting a command which enables me to view all documents in the folder. After I find the name of the document, I am also unaware of how I can use command prompt to copy the file onto the USB i have inserted.
I am accessing the command prompt through System Recovery. I do not know code in any form. IMPORTANT Information which may be the reason for the lack of ability to do anything. When I type prompt>dir ****.docx /s /p, I get the message Volume in drive C has no label rather than Windows 7.
This could help-
http://www.dummies.com/computers/operating-systems/windows-xp-vista/how-to-search-for-files-from-the-dos-command-prompt/
As for copying files in cmd, it's as easy as-
prompt>copy <source> <destination>
For changing the drive (to the USB drive), use the "/d" option-
prompt>cd /d <USB drive name>
To view all the contents of current directory, use "dir"-
prompt>dir
Basically, you're not using right syntax. Kindly make cd c:\users and than write dir like this C:> cd C:/Users than your directory will be changed after that you can see C:/Users. So you can write dir in order to see your directories

I can't see pasted files in bash for windows

I'm working a programming project from school and decided to give Bash for windows a try. I downloaded the skeleton files for the project and pasted them inside the folder where my bash home folder should be. When I open the terminal and go inside the folder it shows as if there was nothing there even though I'm at the right folder. How can I get the files to be displayed?
EDIT: By now, there is actually a supported way to access these files. You have to use the \\wsl$\Legacy "network" share. For example, you could access your WSL home folder in Windows using \\wsl$\Legacy\home\<username>. Still, you should not directly access the lxss directory.
You are not supposed to touch the LXSS folder ever. The files there are use special attributes which are not understood by normal Windows applications to provide the features of a full Linux file system which NTFS on its own can't provide.
There is one hard-and-fast rule when it comes to Bash on Windows:
DO NOT, under ANY circumstances, create and/or modify Linux files
using Windows apps, tools, scripts, consoles, etc. Creating/changing
Linux files from Windows will likely result in data corruption and/or
damage your Linux environment requiring you to uninstall & reinstall
your distro! Note: Your “Linux files” are any of the files and folders
under %localappdata%\lxss – which is where the Linux filesystem –
distro and your own files – are stored on your drive
If you want to copy a file into a WSL directory which is not under /mnt, then use WSL to copy the file, i.e. use cp /mnt/c/original/folder/of/the/file.txt ~/ for example.
A more advanced alternative is starting a local SSH server in WSL and using Win-SSHFS to mount the WSL root as a drive in Windows. This way, file access will go through WSL.
Its unclear what you're asking in your question. What did you paste? Whole files? Text? Where did you paste it? Did you do the pasting into the bash window? If so was it inside a text file or did you just paste to the prompt? I'm going to assume that you pasted files to the directory that you believe that your bash home opens in i.e ~/. You may not be pasting the files into the correct directory because the default directory for bash on windows is not where you would assume it to be. you should be able to reach your desktop by typing cd /mnt/c/Users/yourUserNameHere/Desktop

Issue with win cmd finding folders

I am having an issue with the windows cmd line. When I cd into my Users dir my user folder shows as there but I cannot cd into. The path cd\Users\gmenfan83\ is my desired location. However, when I am in the Users dir and cd\Users\gmenfan83 \ I get a "The path is not found or specified" . I am more of a nix user but if the folder shows in the directory tree shouldn't I be able to cd into it? Thank you
Are you trying to use cd/Users/gmenfan83 while you have already used cd/Users? In that case you will not be able to find the file since you are already in the Users folder. Typing cd \Users\gmenfan83 right after opening cmd with C drive path should get you there.
It's unclear (even after your edit) what specifically you're doing, but this should get you started.
If you're currently in C:\users, and you want to change into the C:\Users\gmenfan83 folder, all you need is cd gmenfan83. If you're in C:\, all you need is cd users\gmenfan83.
Relative paths also work in Windows cmd.exe just as they do under *nix. To change from C:\users\gmenfan83\test to C:\users\gmenfan83\temp, you can use cd ..\temp, or specify cd \users\gmenfan83\temp.

Using mklink command with network drives

I have two network drives that I access through Windows 7: V:\ and T:\ I am trying to create shortcuts between the two that alphabetise with folders (rather than files), so I am using the mklink command:
mklink /d \Photos V:\Photos
which creates a symlink at C:\.
I can move the symlink around locally. However, when I try to move the symlink to a network location, it begins copy the actual files over rather than symlinking them.
I figure that if I can create a symlink of a network drive on a local drive, what's stopping me creating a symlink of a network drive on another network drive. Am I correct in assuming this?
Is there any way to designate the destination file path when creating symlinks with the mklink command? Or is there any way to move symlinks to a network drive at all?
If you need to make a directory junction (using /J) on a network drive, you can first creation a directory (/D) symbolic link and then create a junction off of that, like so:
mklink /D D:\shareLink \\network\share
mklink /J D:\junctionLink D:\shareLink
You need to enable local to remote links by running this command with elevated rights:
fsutil behavior set SymlinkEvaluation L2R:1
Also you can enable this with your local or group policy:
Computer\System\Filesystem\Selectively allow the evaluation of a symbolic link --> allow local to remote
You will need to log onto the computer hosting the network drive and run the mklink command from there.
I recommend creating a junction /J instead of a symlinkd /D. Symlinks have some additional settings you need to be aware of. See symbolic-link-cannot-be-followed.

Resources