But I am looking for a code that will allow whatever user that uses my batch file to get to their my documents. The idea is that they would type 3, press enter, and then the program would open up their "My Documents" folder.
Unfortunately every user has a different name, so the following command won't work unless it has a specific name after it.
%SystemRoot%\explorer.exe c:\users\James\My Documents
Is there some sort of replacement for the "James"? A universal command?
You can use the %UserProfile%
environment variable, which points directly to the personal folder of the logged in user:
%SystemRoot%\explorer.exe %UserProfile%\My Documents
-If you're using windows 7 just do explorer %UserProfile%\Documents (should work with other Windows but I haven't tried...)
this is because any exe in system root can be used as a command and to my knowledge most versions of windows have a folder called "Documents" not "My Documents" it just appears that way to the user (same for Music etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With