I recently got a new flash drive that I am devoting entirely to my programming work (mainly python).

Because I use my flash drive all of the time, I have a lot of important documents that I have on my flash drive, that would be disastrous to lose. The nature of my job, however, is that I am constantly switching computers, and sometimes don't have time to upload documents I worked on to the cloud as a backup. Plus downloading of some of my projects can take quite a bit of my time if I'm working on a large project, so using only a cloud storage system like dropbox would be bad. What I want to do is create a python autorun script so that the moment I plug in my flashdrive, it uploads the program files in the background while I work in the foreground. The actual python script I will ask about later, if I have troubles.

Right now, however, my issue is getting autorun to work. I looked up a bunch of tutorials and followed their instructions to the letter about creating autoruns and batches and such, but every time I try to run the program when I plug in my flashdrive, Windows 8 (my home computer) tells me there's a problem with the flashdrive and asks if it can scan and repair it.

autorun.inf:

[Autorun]
open=autorun.bat
icon=python.ico
label=PythonDrive

autorun.bat:

"Portable Python 2.7.5.1\Python-Portable.exe" "autorun.py"

I have the files all in the main directory of the flashdrive. The icon and label command seem to work for my flashdrive, but if I get rid of the open command, the computer still complains. I would prefer just executing the python without a batch, but I was hoping that a batch file might work better than a python file being executed from portablepython. the batch file does work, if I manually open it.

I found this article which mentions that you can no longer (in windows 7) use the open command in autorun.inf. Is this true? If so, how do I work around it?

有帮助吗?

解决方案

This will work to mirror your flash drive to c:\ on Vista and higher. XP too if you download Robocopy from MS.

@echo off
robocopy "%~d0\" "c:\flash-backup" /mir

Beware and make sure you make a secondary backup now and then: if your flash drive becomes corrupted and you don't realise it for some time, and have used the flash drive in all your machines, then all your backups will be corrupted too.

Backups are too important to leave solely to automated methods.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top