If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
cmd files
I would appreciate some help with a problem I am having. I have some cmd
files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . |
Ads |
#2
|
|||
|
|||
cmd files
Dond13 wrote:
I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . If you call the .cmd file from a shortcut, or from a cmd.exe window,, you can pass the F: G: or H: argument on the command line, then within the .cmd file replace your hard coded drive letter with %1 |
#3
|
|||
|
|||
cmd files
Use a generic target in the cmd file and then put the cmd file on the
flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . |
#4
|
|||
|
|||
cmd files
On Mon, 29 Nov 2010 14:06:16 -0600, Dond13 wrote:
I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . I am confident of the below, modulo any typos, but I haven't tested it so you should. :-) 1. In your existing cmd file, change all the f: or g: or h: to %1: (that's percent, 1, colon). 2. Insert these lines at the beginning of the file: @echo off if "%1" == "f" goto 00_Start if "%1" == "g" goto 00_Start if "%1" == "h" goto 00_Start echo Specify drive letter f, g, or h. goto 99_Exit :00_Start echo on -- add this line if you wish 3. Append this line at the end of the file: :99_Exit 4. Call your file by "filename f", "filename g", or "filename h". The lines in 2. above will catch a mistake. -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com Shikata ga nai... |
#5
|
|||
|
|||
cmd files
"Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. |
#6
|
|||
|
|||
cmd files
"Dond13" wrote in message ... "Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. 2 ideas for you, both of which will work. Put a specific "marker" file in the root of the USB drive (or drives) that are appropriate for receiving backups. Now modify your backup script to go through available/used drive letters looking for said file. backup to drive that contains that file. Or, put your USB drive in. Go into Disk management and manually change the drive letter of the USB drive to something high up in the alphabet (when Windows is auto-assigning drive letters it does it in order) so it will always be the same letter (but not all the way to Z as when mapping network drives Windows starts at Z and works it's way backwards). Now modify your backup script to use that specific drive letter. |
#7
|
|||
|
|||
cmd files
On 30/11/2010 11:32, Dond13 wrote:
"Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. There's no way to do it with just the simple icon method you're using. Best alternative is to have several commands in a folder; BackuptoG.cmd BackuptoH.cmd etc. If you want you can then create icons for each one; DoG, DoH etc. Similarly for restores. Ed |
#8
|
|||
|
|||
cmd files
"Ed Cryer" wrote in message ... On 30/11/2010 11:32, Dond13 wrote: "Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. There's no way to do it with just the simple icon method you're using. See the reply I sent the OP for 2 ways it can be done with a single icon/CMD file. |
#9
|
|||
|
|||
cmd files
"Ed Cryer" wrote in message ... On 30/11/2010 11:32, Dond13 wrote: "Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. There's no way to do it with just the simple icon method you're using. Best alternative is to have several commands in a folder; BackuptoG.cmd BackuptoH.cmd etc. If you want you can then create icons for each one; DoG, DoH etc. Similarly for restores. Ed That is the way I am doing it now. I just thought that there was an easy way to receive keyboard input within the cmd file. I thought that I remembered from the distant past that you could do this but I have worked on so many different systems and with so many different languages that I might be thinking about my days with IBM mainframes, or some of the languages I have used in the past. I would like to thank all who have made suggestions, but I'll just continue with several .cmd files - one for each drive that I use. I use several because I make backups to a CF, SD and to an external hard drive. I don't think that I can have enough backups of the files I am talking about. Thanks!! |
#10
|
|||
|
|||
cmd files
"Seth" wrote in message ... "Dond13" wrote in message ... "Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. 2 ideas for you, both of which will work. Put a specific "marker" file in the root of the USB drive (or drives) that are appropriate for receiving backups. Now modify your backup script to go through available/used drive letters looking for said file. backup to drive that contains that file. Or, put your USB drive in. Go into Disk management and manually change the drive letter of the USB drive to something high up in the alphabet (when Windows is auto-assigning drive letters it does it in order) so it will always be the same letter (but not all the way to Z as when mapping network drives Windows starts at Z and works it's way backwards). Now modify your backup script to use that specific drive letter. Seth, I can see how your solution would work but I was looking for something a little more direct. The steps required for this would be a little cumbersome and would have some unintended consequences if I goofed for instance and didn't reset Disk management after finishing. The multiple icons for several .cmd files will continue to work and I just have to ensure that each one is edited if I add or delete anything I want to backup. Thanks! |
#11
|
|||
|
|||
cmd files
Dond13 wrote:
I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. Right click the shortcut, properties, change the "target" so that it inncludes your F: G: etc you might need to put double quotes round it, e.g "C:\Whatever folder\backup.cmd " F: sorry not in front of a windows PC right now, but you should get the idea. |
#12
|
|||
|
|||
cmd files
Ed Cryer wrote:
There's no way to do it with just the simple icon method you're using. Best alternative is to have several commands in a folder; BackuptoG.cmd BackuptoH.cmd Rubbish! |
#13
|
|||
|
|||
cmd files
On 30/11/2010 14:33, Dond13 wrote:
"Ed Cryer" wrote in message ... On 30/11/2010 11:32, Dond13 wrote: "Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. There's no way to do it with just the simple icon method you're using. Best alternative is to have several commands in a folder; BackuptoG.cmd BackuptoH.cmd etc. If you want you can then create icons for each one; DoG, DoH etc. Similarly for restores. Ed That is the way I am doing it now. I just thought that there was an easy way to receive keyboard input within the cmd file. I thought that I remembered from the distant past that you could do this but I have worked on so many different systems and with so many different languages that I might be thinking about my days with IBM mainframes, or some of the languages I have used in the past. I would like to thank all who have made suggestions, but I'll just continue with several .cmd files - one for each drive that I use. I use several because I make backups to a CF, SD and to an external hard drive. I don't think that I can have enough backups of the files I am talking about. Thanks!! I presume that the "icon" is merely a Windows shortcut that you've created for the .bat file and then changed the picture. Seth's method of changing the target would work, but (and I guess both you and I have experience of writing software for "other users") it takes attention whenever used, is easy to get wrong, quite difficult to teach to Joe Soap, is not user-friendly. I worked with ICL mainframes; systems designer, analyst-programmer, sometime system programmer; and I guess we think alike, having had to earn our bread with it. With the old ICL George and VM OSs the macros could all take string parameters; things like %(driveletter). That was probably true of IBM as well. Ed |
#14
|
|||
|
|||
cmd files
"Dond13" wrote in message ... "Seth" wrote in message ... "Dond13" wrote in message ... "Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. 2 ideas for you, both of which will work. Put a specific "marker" file in the root of the USB drive (or drives) that are appropriate for receiving backups. Now modify your backup script to go through available/used drive letters looking for said file. backup to drive that contains that file. Or, put your USB drive in. Go into Disk management and manually change the drive letter of the USB drive to something high up in the alphabet (when Windows is auto-assigning drive letters it does it in order) so it will always be the same letter (but not all the way to Z as when mapping network drives Windows starts at Z and works it's way backwards). Now modify your backup script to use that specific drive letter. Seth, I can see how your solution would work but I was looking for something a little more direct. The steps required for this would be a little cumbersome and would have some unintended consequences if I goofed for instance and didn't reset Disk management after finishing. The multiple icons for several .cmd files will continue to work and I just have to ensure that each one is edited if I add or delete anything I want to backup. You misunderstand... It's a 1 time process (insert USB stick, go into disk management and change letter to S:, done). Now, as long as "S:" isn't occupied (which is unlikely as it is far enough away from Z and C), that USB stick will always come up as S: when inserted. What part is cumbersome and where do you have to reset something in Disk management? And also don't ignore the other method of making (1 time) a "marker" on the USB drive and having your backup script find the marker. |
#15
|
|||
|
|||
cmd files
"Dond13" wrote in message ... "Ed Cryer" wrote in message ... On 30/11/2010 11:32, Dond13 wrote: "Bob I" wrote in message ... Use a generic target in the cmd file and then put the cmd file on the flash drive and run it from there. On 11/29/2010 14:06, Dond13 wrote: I would appreciate some help with a problem I am having. I have some cmd files that I have written to backup specific folders to a flash drive. I want to be able to change the physical drive using either an entry calling the cmd file or imbed a command within the file to be able to change the physical address of the drive. Sometimes I use F: G: or H: and don't feel it is necessary to have separate cmd files for each drive. I have been a programmer in another life, but am an old fart now and can't get it done as I could in the past. I just need help. . That's what I had in mind, and I do call the .cmd file from a shortcut. I have one icon for backup and another for restore. I don't know how to pass the argument to the .cmd file. I must be missing something basic. I understand that I would write the .cmd file with %1 signifying the drive letter, and I can see how to do that using a cmd window but how do I pass the argument to the file called by the shortcut? I might not be making myself clear, but I have a file 'Backup.cmd' and have created an icon that will execute the file when I click on that icon. Sounds basic but I'm lost as to how to accomplish passing the parameter to specify which drive I want to backup. Oh to be 60 again - or even 70. There's no way to do it with just the simple icon method you're using. Best alternative is to have several commands in a folder; BackuptoG.cmd BackuptoH.cmd etc. If you want you can then create icons for each one; DoG, DoH etc. Similarly for restores. Ed That is the way I am doing it now. I just thought that there was an easy way to receive keyboard input within the cmd file. I thought that I remembered from the distant past that you could do this but I have worked on so many different systems and with so many different languages that I might be thinking about my days with IBM mainframes, or some of the languages I have used in the past. I would like to thank all who have made suggestions, but I'll just continue with several .cmd files - one for each drive that I use. I use several because I make backups to a CF, SD and to an external hard drive. I don't think that I can have enough backups of the files I am talking about. Thanks!! Why not use the CHOICE command? It would look something like this: CHOICE /C:FGHIN /N Backup to drive F:, G:, H:, I: (or N for None)? IF ERRORLEVEL 1 SET DRIVE=F: IF ERRORLEVEL 2 SET DRIVE=G: IF ERRORLEVEL 3 SET DRIVE=H: IF ERRORLEVEL 4 SET DRIVE=I: IF ERRORLEVEL 5 SET DRIVE= ECHO Backing up to %DRIVE% When run, it will prompt "Backup to drive F:, G:, H:, I: (or N for None)?" and will then wait for you to press a key, return an errorlevel for the key based on the order of the /C: parameter, and sets the variable DRIVE to the drive letter. You can then just use %DRIVE% in your backup routine instead of a hard-coded F:, etc. -- Zaphod "The best Bang since the Big One" - Eccentrica Gallumbits |
Thread Tools | |
Display Modes | Rate This Thread |
|
|