.bat file to open a specific folder and copy files from a usb drive - batch-file

I am having difficulties with creating a simple batch file.
What I would like is a batch file that will open up a specific directory and copy 2 files from the same directory that the batch file is in and paste them in the directory that was just opened.
So, in this instance, I have a USB flash drive. I have two IE shortcuts that I would like copied and placed in a public desktop.
The .bat file and the 2 files will all be on the root of the flash drive.
So, my understanding is that it should look like this (EWQ is the IE shortcut and keyfinder is just a test file because i wasn't sure on the extensions... i could not figure out what the IE shortcut extension would be as I don't think it has one):
%SystemRoot%\explorer.exe C:\Users\Public\Desktop<br>
copy EWQ C:\Users\Public\Desktop<br>
copy keyfinder.cfg C:\Users\Public\Desktop
I get my public desktop folder to open but nothing copies. I have
tried various prefixes, like "%~dp0\EWQ" (with an without the quotes)
but to no avail.
These will be loaded from a flash drive and I have about 500 to do so I'd like this as quick and possible. Basically, pop in the flash drive, double click the .bat file and yank it out. In theory, it 'should' be the same drive letter every time, but that isn't guaranteed.
Thank you for any help!!!

This is a batch file, let's call it testing.cmd.
#Copy "%~d0\EWQ.url" "%PUBLIC%\Desktop"
#Copy "%~d0\keyfinder.cfg" "%PUBLIC%\Desktop"
Place this file somewhere on your flash drive and double click it, ensuring that both EWQ.url and keyfinder.cfg are in the root of that drive. If you do not have access to the destination you could try by right clicking testing.cmd and choosing Run as administrator.

Related

Drive File Stream altering my file names to add (1) at the end of their names

I am writing a program using WinForms in C# which monitors my drive file stream files, and copies the files to a local directory, where the files can then be run locally off of the computer.
My issue I am having is that when I alter or replace the files in the drive file stream either through the desktop app or the browser, it will rename some files to add an additional (1) at the end of the name. This then messes with the files when I need to run them from the local directory on my computer, as it cannot locate these specific files anymore.
Does anyone have a solution for this? Thanks.

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

Unable to copy file to system32 using batch file

I tried to copy a file to System32 with this batch and it said "Access denied":
xcopy "BACKGROUNDDEFAUL.jpg" "C:\Windows\System32\oobe\info\backgrounds\"
pause
Is there a way to do it? If not, why?
C:\Windows\ contains the operating system. You can't directly modify the files in it and its subfolders (such as System32) because an improper modification can break your computer.
To set a picture as background, right-click it and click "Set as desktop background".

Open a .bat file, out of a folder, off a flashdrive

I have a game that I'm making off of my flashdrive, and I'm trying to make a save feature into an RPG game. I know I can just save all the data into a character bat file, and then call that bat file, but the problem is that my flashdrive looks cluttered whenever multiple characters get formed. understand? I need to beable to load a save, from a character folder (for organization) from a changing source folder, (Because the flashdrive will be in different USB ports, such as :E or :F etc.)
You can determine the drive that a Windows batch file uses by using the CMD variable substitutions. Within a batch file, you can determine where the file resides.
%~d0 is the drive. %~dp0 is the directory. And there are more.
See What does %~dp0 mean, and how does it work?

Copy files automatically from usb to specific folder with specific extensions

I have huge amount of flash drives and I need to backup my files on specific folder (for example C:\Backup).
There are two problems :
1. I need to backup files with .doc and .docx extension only.
2. When flash drive is inserted, I want that files would copy automatically.
(It's loop if I remember)
Is there any batch solution for this?
try this tutorial for autoplay USB
Then, i am thinking, instead of the autoplay.exe you can set it to run a batch file instead.
In that batch file use the xcopy command.

Resources