check if drive is realy a USB ussing batch - batch-file

I have a random number thats generated and placed in a text file. i would like that file to be saved automaticaly to a USB drive only.
Is there a way in batch to ensure that the file is saved to USB only?

The simple answer is you can't. You will need to use a real programming language, or maybe vbscript at the very least, and even then it's very hard to ensure you are actually getting real USB drives.
See here and here for some vb samples.
Then if you do, you can use batch to call the script using cscript.exe.

Related

Quickest way to create a .bat file (as .txt)

I have a couple lines of code in a batch file in Windows 10 that open a session of Octave, and load a script that uses design parameters contained in a .txt file. The batch file is named (for example) "Design123.bat", and when Octave runs, it automatically finds the design parameters in the file "Design123.txt" by simple string manipulation of the file name, i.e. strrep(filename,".bat",".txt"), where filename = '%~dpn0' is passed to Octave from the batch file. This allows for the contents of the batch file to stay simple and constant, and the file name of the batch file is the only thing tying it to the .txt file.
I do all of this to allow running the Octave script by double-clicking the batch file for convenience, instead of being forced to use the more tedious process of uigetfile in Octave. This works very well, but the catch is that I have to place a copy of the batch file in the same directory with the design (.txt) files (of which there are thousands, but each within their own directory) and give it the same file name to get it to work. Is there a way to quickly create the batch files somehow? The most ideal situation I can think of is to be able to right-click (or somehow select) a .txt design file, and create a batch file (replacing .txt with .bat) and place my lines of code into it.
Any ideas? I have coding experience, but only in software packages like VBA and Octave, not within operating systems themselves, though certainly willing to learn if I could get pointed in the right direction. The design file names follow a distinctive pattern, so they could be filtered easily within an operation on the active "File Explorer" window in Windows 10, if something like that is possible. Thanks in advance.
You might want to compose the answer to your question from calling the script on the right click and running the .m script with command line arguments.
If that fails, uigetfile is certainly not the only method to get file. At the very least you could always copypaste a path string to a folder from explorer to octave function call.
Finally, I guess I'll mention the existence of octave-cli which runs in terminal instead of gui. It might be better suited for running non interactive scripts.

How can I use a Portable Hard Drive label name instead of the Drive Letter?

So here's my problem.
I'm making a batch (working from inside the hard drive) to open a hided system folder on the hard drive, and with that two .vbs files. It all works great, but when I go to another computer with the same hard drive, obviously the drive letter changes so my code doesn't open the folder I need, but instead any other one from the computer that attempts to use the batch.
So I need to make it open the Hard Drive, by his name. Which is Albandart.
How can I change this code to work with the label name of the hard drive?
%SystemRoot%\explorer.exe "A:\System\PAOutput"
#explorer A:\SystemFiles\PAe.vbs
#explorer A:\SystemFiles\PAs.vbs

It's possible to make a Batch program that backup a folder files from my external hd to pc hdd, anytime I add or change a file?

I'm a graphic designer and I use my external hd frequently to move psd/jpeg/png/tiff files from my laptop at home to my Work PC and vice versa. But as a precaution before modifying or adding a file I copy it to a folder. It's possible to make it automatically? And it's easy to make on Batch?
Thanks for help!
Robocopy is your friend; google it and have a look. It's a very powerful program by sysinternals (owned by Microsoft). Alternatively, if you want a nice GUI to go with it use SyncToy (https://www.microsoft.com/en-gb/download/details.aspx?id=15155) which can be run with a batch file (including arguments) or made into a scheduled task.

How can I create a bootable dvd with custom DOS boot script?

We have a bootable USB stick that works perfectly. It will boot, ask the user for some options, then write files to the hard drive accordingly. We did this by using rufus-2.1, throwing freedos into the USB stick, and basically hijacking autoexec.bat. Autoexec.bat now executes some separate .bat scripts based on user input.
The problem is, we now want to have an option to allow users to burn an iso to a cd or dvd. We've been trying to create an image of the USB stick and burn it to a DVD.
We found plenty of information on this subject, but nothing has worked. We started by extracting the bootimage from various bootable iso files using imgburn. None of these worked. We tried extracting the bootimage from our USB stick, and that also didn't work.
Next we tried WinImage. We extracted the boot information from boot98.exe, hijacked autoexec.exe, created a new image and injected the files. We saved the files as a bootimage and tried the above method again, which also didn't work.
Is there perhaps a more straightforward way to execute DOS .bat scripts through cd/dvd boot? We'd be open to something other than DOS as well, as long as it can write files to a hard drive based on user input through a simple boot interface.
Note: The computer itself does not contain an operating system.
Thanks.
We found a very slick setup that does what we need. Unfortunately, the CD-ROM drivers do not work properly on modern DVD drives. Using this method, it should be possible to put all the scripts directly in autoexec.bat and run commands directly on the "simulated" floppy drive. For whatever reason, we can boot from the "floppy" section of the CD-ROM, but it cannot copy files from A: to C:. I believe we are very close, but no cigar.
http://www.hiren.info/pages/bootablecd
First method that actually produced a bootable CD and allowed scripts to be run by a choice entered by the user.

how to load a hex file into a microcontroller using batch

I'm trying to write a batch file that does a few things... having trouble with it.
I can't find any examples to help me, but what I need is...
run 3rd party program to create 1 .hex file
load that and 2 other .hex files into a microcontroller
in windows 2000 and above, you cannot do this. due to the limitations of batch.
in DOS you would be able to, with the APPEND command, but it doesn't exist in new operating systems.
Bill Gates just took it out.

Resources