Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 MS-Dos Question
Index -> General Discussion
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
pileggi




PostPosted: Fri Dec 01, 2006 11:52 am   Post subject: MS-Dos Question

I'm making a batch script that will automatically run when I plug my USB Flashdrive into a computer, but I'm wondering how I can get the Drive letter for my USB?

my script copies files from the computer automatically, and I can navigate to those files easy enough, do a copy, but how do I code the Flashdrive.. each time it goes into a computer the drive letter might change. Is there an autodetect ? or a jump2home kind of thing?

Working in MS-DOS for XP
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Dec 01, 2006 12:17 pm   Post subject: (No subject)

There is no "MS-DOS" on Windows XP. It has been discontinued since Windows ME. Both XP and 2000 run on NT base.

Now that you've caught up on the last 6 years of technological advance in Microsoft's Operating Systems...

I'm fairly sure that there got to be autorun type of executables available for USB media. It would be far better to execute scripts from a particular USB drive, rather than dump files onto anything that touches your port.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
r.3volved




PostPosted: Fri Dec 01, 2006 12:28 pm   Post subject: (No subject)

Have you tried "Send To:"?
Are you trying to have an autexec batch file, or an autoexec executible??

You should also be able to navigate to it by the name of your USB device.
ZeroPaladn




PostPosted: Fri Dec 01, 2006 1:15 pm   Post subject: (No subject)

Im not very sure if this will work for what your using, but...

The Letter of your USB post never changes, its all a mater of plugging in your USB Flashdrive, going into driver settings, and look for a usb flashdrive. it should give you the letter of that peticular usb port, along with the name/makeof your flash drive. There should be autoexec thing under the setings of the usb flashdrive saying to open a certain program once the drive is plugged in (like Windows explorer at the location of your flashdrive, perhaps). then its all a matter of running a copy script. I got that running for my usb connector for my DS, it autoexecs the program for it when it is plugged in and detected. Its really neato.
Mazer




PostPosted: Fri Dec 01, 2006 3:12 pm   Post subject: (No subject)

There's stuff that does this already. I think it's called USB Hacksaw, but I really can't be sure. You can check out this show in which they demonstrate using it.
rdrake




PostPosted: Fri Dec 01, 2006 3:44 pm   Post subject: (No subject)

ZeroPaladn wrote:
The Letter of your USB post never changes
It can and does change when you have multiple devices plugged in and when you change around your drive configuration.
pileggi




PostPosted: Sat Dec 02, 2006 10:17 am   Post subject: (No subject)

Maybe I was a little unclear, the batch script is on my USB Flashdrive, so i'm trying to run the file in the opposite way you guys are talking about.

I have the script on my USB, I go to some place, plug the USB in.. I want it to automatically copy certain folders from that computer, onto my USB, using this script.

I know how to navigate directories, I know where the files are, but I don't know how to make the actual XCOPY statement that will refer to my usb.

code:

ex.

cd C:\
cd Tempfiles
cd Stuff
XCOPY picturesfolder myusbdrive /E




XCOPY [source] [destination] [E: everything, including subdirectories]
I just don't know what to put in the "myusbdrive" area, since different computers will have different drives, and so the drive letter of my USB will change.

(And I know its not MS-DOS, but I figured you guys would know what I meant anyway. "Command Prompt", make you feel better now?)
rdrake




PostPosted: Sat Dec 02, 2006 2:06 pm   Post subject: (No subject)

I can tell you right now it can't be done without another program.

Microsoft wrote:
Q: What must I do to trigger Autorun on my USB storage device?
The Autorun capabilities are restricted to CD-ROM drives and fixed disk drives. If you need to make a USB storage device perform Autorun, the device must not be marked as a removable media device and the device must contain an Autorun.inf file and a startup application.

The removable media device setting is a flag contained within the SCSI Inquiry Data response to the SCSI Inquiry command. Bit 7 of byte 1 (indexed from 0) is the Removable Media Bit (RMB). A RMB set to zero indicates that the device is not a removable media device. A RMB of one indicates that the device is a removable media device. Drivers obtain this information by using the StorageDeviceProperty request.
Source: here.

Thankfully there are programs out there that can enable autorun (somewhat). They sit there and wait for a drive change to occur, executing autorun.inf when it does. You must write an autorun.inf file and put it on the root of the drive, having it execute your batch file. If you are interested in this program, you can find it here.
Sponsor
Sponsor
Sponsor
sponsor
pileggi




PostPosted: Wed Dec 06, 2006 3:09 pm   Post subject: (No subject)

Thanks for all the info guys, actually I figured it out
Yea I knew of the autoexec.ini part , the only trouble I was having was with the coding of the actual script. I figured it out, just stored the initial path to a variable, then cd ed to the other directory, and copied

code:

echo on
.:- Julian's USB FlashDrive is Installing-:.
                    Please be patient               
echo off
set cur=%cd%
cd C:\
cd Documents and Settings\Julian\My Documents
xcopy "my chat logs" %cur% /C /H /E
pause



set current directory to variable "cur"
changed directory,
copied with xcopy
voila

Now I just have to figure out a way to make it so the freakin command prompt doesn't pop up and show me copying all those files...
anybody know how to make a batch script run minimized, or invisibly?

I figure I could make it a self-extracting archive with Winrar, and set the script to run when the archive opens, minimized. But thats involving Winrar then, there should be a way to make a batch script run minimized natively, right?[/code]
Display posts from previous:   
   Index -> General Discussion
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: