English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Im stuck on my extremely limited knowledge on writing batch files and what i have got doesnt work.

What i need is a batch file to send out to all users within the company i work for which will copy two files (*.id + names.nsf) out of the following destination:

C:\Program Files\Lotus\Notes\Data

and then pasting them on the root of U:\ (each user has their own drive which we have designated this to be it.)

I have done some research around on the internet but i just cannot find what i am after and continue to tie myself around in knots.

If you could help me it would be a great help!

Cheers,
Josh.

2006-06-21 09:46:14 · 4 answers · asked by ornge_sherbert 3 in Computers & Internet Programming & Design

4 answers

davidmi711 has a good start.

Check out http://www.generation.net/~hleboeuf/dos7comm.htm for more info.

But there is no sanity checking or error handling.

SANITY CHECK – First off, if for some reason a user does not have their U:\ mapped the copy will fail and throw an error. So First we need to check that the drive is mapped. This can be done using “Net Use”. What this does is tries to map the drive again. But to map the drive we need to know the path to the user directory to map to (the users home Directory), assuming this is done on a Windows OS of 2000 or higher the dos variable %HOMESHARE% should be set to that. (if not, just let me know)

ERROR HANDLING – the dos variable %ERRORLEVEL% is used to see if the previous dos command was successful or not. Following all major commands with a check of errorlevel allows us to see where the script is breaking.

All you have to do is copy the script below into a text file, and save it with the .bat extension. This should solve your problem.

@echo off

rem SANITY CHECK
rem This will map %homeshare% to the computer as U:\
net use %homeshare% U:\

rem ERROR HANDLING - if something does wrong let the user know
if errorlevel 1 goto errorNET


rem COPY FILES
rem This is the same as davidmi711 suggested
copy C:\Program Files\Lotus\Notes\Data\*.id u:\
copy C:\Program Files\Lotus\Notes\Data\names.nsf u:\

rem ERROR HANDLING - if something does wrong let the user know
if errorlevel 1 goto errorCPY

rem If No errors let the user know all is well
echo.
echo Copy Completed with no errors!
echo The IT Staff thanks you for your time.
rem Since there were no errors skip to the end.
goto end

rem ERROR HANDLING
:errorNet
echo A network error has been found.
echo Please contact IT for assistance.
goto end

:errorCpy
echo An error has been found in the copy process.
echo Please contact IT for assistance.

:end

2006-06-21 10:34:28 · answer #1 · answered by boter_99 3 · 4 1

Copy the script below into a text file and name it something like script.vbs (it has to have the vbs extension).
when the users doubleclick on the file, it will do the copy.

==============================
dim filesys,fname1,fname2

strFname1="*.id"
strFname2="names.nsf"
strSourceFolder="C:\Program Files\Lotus\Notes\Data\"
strDestFolder="U:\"


set filesys=CreateObject("Scripting.FileSystemObject")

filesys.CopyFile strSourceFolder & strFname1, strDestFolder

If filesys.FileExists(strSourceFolder & strFname2) Then
filesys.CopyFile strSourceFolder & strFname2, strDestFolder
End If

2006-06-21 10:08:49 · answer #2 · answered by Anonymous · 0 0

@echo off
copy C:\Program Files\Lotus\Notes\Data\*.id u:\
copy C:\Program Files\Lotus\Notes\Data\names.nsf u:\

2006-06-21 09:51:22 · answer #3 · answered by davidmi711 7 · 0 0

Not sure if you can do it, because having two actions on the same line only works for certain programs with pre-specified parameters, like starting firefox, and then a specific, or several specific web pages.

2016-05-20 09:33:17 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers