Why does this batch file fail for some users? - windows

I have a batch file that copies the most recent version of an access front-end file to the user's C: drive and then opens it from there.
For some users, the copy command causes the batch file to close, and I can't work out what could cause that. The file seems to copy, but the batch file just closes itself without any visible error messages.
I've used Pause to confirm that the failure happens at the Copy step, not the Run or the If.
This is Windows 7, I've tried it with Copy and Xcopy. The users with the issue say it's worked in the past, they all have access to the location being copied from (and to). Mapping the location doesn't seem to make any difference, and UNC paths work for most users so it's not that.
Deleting the existing files in C:\databases doesn't help.
if not exist "C:\Databases\" mkdir "C:\Databases"
copy "\\SERVER02\FINOPS\COMMAQR\DIGIHUB\1. Live Version\DIGIHUB v2.5.accdb" "C:\Databases\"
start [the file]
For 95%+ of users, the batch file copies the most recent version down and opens the file. For a handful, the batch file reaches the copy step and closes itself.
Does anyone know why this could happen, or alternatives to both Copy and XCopy that might not fail?

Related

Xcopy sharing violation, how to still copy without skipping

I’m copying files from one directory to another with Windows xcopy command in cmake. Sometimes I run into situations where one file is already being used by another program, which results in a sharing violation error. Therefore, the file does not get copied and my compilation fails.
How do I get around this without skipping over files that are already being used. I don’t have the option to close any open files.
Any guidance would be greatly appreciated.
The only way is to kill the process or program which uses the file that you are copying via task manager and try again.
/c will be used to skip the file and continue copying but in your case, you dont want to skip the files that are already being used.

Drag N' Drop 100+ Files Batch

I've been searching for an answer on the internet and can't seem to get a definitive one. I've been having an issue with getting a .bat file to accept more than 80 files at once for conversion and file look up with a batch script that links to a python script.
Here is an example of what I'm doing, it's easy enough...
#ECHO OFF
python "C:\myDirectory\Conversion_and_Excel_Extractor.py" %*
PAUSE
Again, this seems to work with 80 files drag and dropped unto the batch script but doesn't seem to work with more than that. Is there something I'm doing wrong?
they are located in their own directory. I would prefer to drag the
entire set of files, or the entire directory, into my batch file and
iterate over the files
that's possible:
drag the folder to your batch file and use
python "C:\myDirectory\Conversion_and_Excel_Extractor.py" "%~1\*"
As an alternative you could drag any one of the files to the batch file and use %~dp1 to get the folder and
python "C:\myDirectory\Conversion_and_Excel_Extractor.py" "%~dp1\*"
to process all files in this directory.

Moving files in shell script and copying files to the same folder at the same time

I am writing a shell script to move all files from one directory to other. Say I want to move all files from directory dirA to directory dirB. When the move is in progress, some user is copying some files to dirA. How do I ensure that, whatever file the shell script is trying to move, has finished copying? What would happen if we try to move a file which is still being copied?
The list of filenames is generated as soon as the move command is issued. Any changes after that will not be taken into account. So if new files are created during the move process, they won't get impacted.
You may have to run your script in a loop.
If one of the files that is part of the move command is still being modified (after being opened in its old place), the changes would
propagate to the new place when the change operation is complete and the file is closed.

Running program/macro to rename, add files to flash drive

I have a huge batch of flash drives that I need to move files onto. I'd also love to rename the drives (they're all called NO NAME by default). I'd love to plug two drives in, run a terminal script on the computer to accomplish all of that (most importantly the file moving). Then remove the drives, put the next two in, run it again, etc. until I'm done. All of the drives are identically named.
Is batch executing like this possible, and does anyone know how to go about doing it?
I figured it out. Put each one in and run this command to rename the drive and then move the files into it:
diskutil rename /Volumes/OLDNAME "NEWNAME" && cp -r ~/Desktop/sourceFolder/. /Volumes/NEWNAME

How to start an application in a given directory, using other as its working dir?

For a system we are deploying for our customer we need to run the setup executable from %temp% and have it use for the installation, files in another directory.
This cannot be solved at the application level.
So, basically what I need it to somehow "cheat" the setup.exe located at %temp% to think it ran under another directory.
Any ideas?
I tried doing pushd & popd, that doesn't work because the OS tries to call setup.exe from the data files' directory, not setup.exe.
I also tried calling setup.exe by running a bat from the data files directory, that basically calls it by doing:
%temp%\setup.exe
doing:
cd %temp%
setup.exe
also failed
cd %files_dir%
%temp%\setup.exe
But
1) it's up to setup.exe to use current dir or not. So this command sequence can have no effect.
2) current dir can be changed at any moment (e.g. when system Files Open dialog is called).
You can try to create shrtcut of files in %temp% dir and use them instead of files. Maybe you'll need to play around with file extensions.

Resources