1

I'm trying to run some programs from a flash drive. Therefore, I want them to keep their data on the drive as well. I know how to do this using the following batch script;

APPDATA=%CD%
Program.exe

However, using multiple batch scripts is quite inconvenient. I've seen certain commands in the target section of a shortcut. For example when using a web browser;

"C:\Program Files\chrome\chrome.exe" http://"www.google.com"

Now, I'm trying to add the APPDATA=%CD% command into a shortcut, so that the data is kept on my flash drive instead of the host computer. Does anyone know how I can do this?

I'm using Windows 10, but the command should work on all modern Windows versions.

An example of what I'm trying to do.

12
  • Please provide a screenshot of the shortcut configuration you're trying... Commented Dec 16, 2015 at 20:37
  • Which version of Windows? Also, consider editing your question to include your comment.
    – Steven
    Commented Dec 16, 2015 at 20:37
  • Cool. Makes more sense now. ;) So, what makes you think adding that command as a argument to Launcher.exe will have any affect? I ask because that's what you're doing there, and it doesn't really line up with your mentioning of "batch"... Commented Dec 16, 2015 at 20:53
  • Why not just use portable chrome, portable firefox, ...
    – DavidPostill
    Commented Dec 16, 2015 at 21:05
  • 1
    Portable Minecraft - Make a USB stick to Play Anywhere
    – DavidPostill
    Commented Dec 16, 2015 at 21:10

2 Answers 2

2

It appears you are just appending APPDATA=%CD% to the Target field of a shortcut, as an argument for the "launcher.exe" program.

I don't think this is want you want/need, since appdata is a known Windows environment variable, and especially since %cd% only works from a command prompt.

To me it appears want you want to do is set the appdata environment variable, and then run the Launcher.

To set an environment variable from the command line, you need to use the keyword set.

So...:

  • Create a new text file (with Notepad.exe or whatever).
  • Add set APPDATA=%CD% to the file.
  • On the next line, add the full path to Launcher.exe (eg. c:\program files\minecraft\launcher.exe).
  • Save the file someplace, with a batch file extension (ie: whateverYouLike.bat)
  • Change the Target of your shortcut to point to the batch file you just made (instead of Launcher.exe). Ensure you keep the "Start in" ("Beginnen in") field the same, so that the target file is run in that folder's context

So now when you click the shortcut it'll run your batch file, and your batch file will first set the AppData environment variable, and then run the Launcher.exe.

7
  • Yes, I have already done that. Now, I'm trying to do this with a shortcut, as I'm trying to do this for multiple programs and I don't want to create a batch file for every one of them. Commented Dec 16, 2015 at 21:16
  • 1
    You should put that information into your question, so we don't suggest things that are only specific to the info offered and/or that you've tried already. Commented Dec 16, 2015 at 21:19
  • So you asked for "batch" help, yet you don't want to make batch files? How is making batch files (once) any more difficult than changing shortcuts for multiple files? Confusing.. :/ Anyhow, as I said, you can't do it the way you are trying. Perhaps try changing the "target" to set appdata=%cd% & c:\pathtofile\launcher.exe and see if that works (I don't think it will though). Commented Dec 16, 2015 at 21:24
  • I've tried. It didn't work. I guess it really is impossible then. The problem is that, I can't see the icons when I use batch scripts. I just thought there should be an easier way, but I guess there's not. Anyways, thanks for your help. Commented Dec 16, 2015 at 21:36
  • 1
    @JaïrPaalman The portable mincraft link that I included in my answer also addresses how to deal with the icon issues: "Going the extra mile: Getting a Minecraft icon for the USB".You can use the same technique for any batch files you store on the USB drive.
    – DavidPostill
    Commented Dec 17, 2015 at 20:11
2

How do I make a portable version of Minecraft?

If we already had Minecraft installed, it's very easy to convert it to portable Minecraft. We still create the directories on the USB and download Minecraft.exe, but we copy the existing .minecraft folder from the disk to the USB.

To find the non-portable Minecraft folder, we can press the Windows key + R and type %appdata% at the "Run" window.

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 07a

Then, we just copy .minecraft to the data folder on the thumb drive.

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 07b

Create the batch to start portable Minecraft

Finally, we need to create a batch file to start Minecraft. This batch file will tell the Minecraft executable to use the folders on the USB, and not the HDD.

We just need to open a plain text editor, such as Notepad...

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 08

...and type:

set APPDATA=%CD%\data 
"%CD%\bin\Minecraft.exe"

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 09

Afterward, we save the file within the Minecraft Portable folder, along with the bin and data folders.

We can give it a name of our choice, such as "portable Minecraft", or "Minecraft portable", or "launcher". It is important that it has the ".bat" extension, and we have selected "All Files" in the "Save as type".

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 10

If we did it correctly, the system will recognize it as a Windows Batch File.

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 11

This is the file we will run to start the portable Minecraft.

Portable Minecraft: The first launch

The first time we start portable Minecraft, the PC needs to have internet access. It will download the runtime...

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 12

...set up the runtime, which can take a while on a slow USB stick...

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 13

...and then prompt for our Minecraft account credentials.

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 14

Once inside, it's a good idea to check that the proper folders on the USB are being used, instead of the system folders. We click on Edit Profile...

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 15

...and make sure the Game Directory and Executable are both on the flash drive.

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 16

We don't need to make any changes, just check that the paths are on the USB.

After that, we can click on Play. We wait as the system downloads the proper files...

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 17

...and a couple of minutes later, we are on the main menu.

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 18

With a good enough USB flash drive, there will be no difference as if we played off the HDD.

How to Create Portable Minecraft - Make a USB stick to Play Anywhere 19

Since we run the program once, we can now play offline on any PC with the same version of Windows. It won't even ask for the account credentials anymore, the one time was enough.

Source Portable Minecraft - Make a USB stick to Play Anywhere

2
  • Yes, that's what I'm trying not to do. Commented Dec 16, 2015 at 21:33
  • I don't think it's possible to modify the shortcut as you wish.
    – DavidPostill
    Commented Dec 16, 2015 at 21:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .