How do I make a batch file be able to run on other computers

When I create a batch file on my computer to execute start c:\Users\________\Whatever\..., it works on my machine.

How can I get it to work on someone else's machine, since their username isn't my username?


You can use the Environmental Variable %USERPROFILE%. This works from Windows XP and on, and automatically detects the drive letter, and the folder path, to the current user's profile folder.

start %USERPROFILE%\Whatever


You can use the Windows environment variables. One you could use in this case would be %username%, which returns the current user's name.

ie:

start c:\users\%username%\Whatever

Additionally/alternatively, if you're specifically aiming for the user's profile folder (<drive>:\users\<username>) you can use the %userprofile% variable, which will return the full path to the current user's profile, which helps when targeting older OSs like XP (where it's <drive>:\document and settings\<username> by default), or where the profile folder has been moved to a different drive/location.

ie:

start %userprofile%\Whatever

There's several other variables in there that you may find useful in writing batches, I'd advise perusing the entire list. :)