You are not logged in.

#1 08 May 2007 15:40

ceebee
Member
Registered: 08 May 2007
Posts: 2

Problems with Robocopy in windows.

Im trying to get robocopy to display files i copy with the /ndl, but this is just displayed in the log.
Does anyone know any way to remove the directory list and only display the files copied in the command prompt ?

here is some of the script :

Set COPY_CMD=C:\Source\Tools\robocopy
Set COPY_OPTIONS=/MIR /R:3 /w:10 /ETA /TEE /NP /NS /NDL     
( the problem here is that robocopy displayes the entire directorylist with file info, but i want it to not to sad  )

Set LOCAL_FOLDER=C:\UNO Local\%USERNAME%\My Documents
Set BACKUP_FOLDER=%HOMEDRIVE%%HOMEPATH%Backup-LT

Set TARGET_PATH=%BACKUP_FOLDER%\My Documents
Set LOGFIL_PATH=%HOMEDRIVE%%HOMEPATH%Backup-LT.log

Any takers?

thanks for the help.

Offline

#2 09 May 2007 17:46

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Problems with Robocopy in windows.

I'm not exactly sure I know what you're asking and it would've been helpful if you'd included the actual command you're going to issue.  Could you elaborate a little?  And perhaps provide some samples of what it is that robocopy is doing that you're not happy with?

Last edited by bluesxman (09 May 2007 17:47)


cmd | *sh | ruby | chef

Offline

#3 09 May 2007 19:04

ceebee
Member
Registered: 08 May 2007
Posts: 2

Re: Problems with Robocopy in windows.

My problem is this:
Im creating a backup script.
This script is supposed to display all the files it backs up.
The problem im having is that i cannot get the robocopy to only display the filenames without the directory.
Ive tried to use the /NDL command in the script but that only applies to the logfile.
Is there another command that im not aware of that can give me ONLY file names in the display when the backup program is running.

Offline

#4 18 May 2007 12:06

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Problems with Robocopy in windows.

Whenever I've used /LOG /TEE with robocopy, the output and screen have been identical, so I don't know what's going on with your script.  Old version of robocopy perhaps?

I don't believe there's any native function within robocopy to completely exclude the path from the output.  Best I could offer off the top of my head is to NOT use the "/NDL" switch then filter the output through the "find /v" command to remove the unwanted lines ... something like find /v "\" should do the trick.  This won't have any effect on the /LOG file though, you'd have to think about a post-run tidy up to do that.


cmd | *sh | ruby | chef

Offline

#5 03 Aug 2007 16:16

rkillcrazy
Member
Registered: 03 Aug 2007
Posts: 6

Re: Problems with Robocopy in windows.

I'm using ROBOCOPY too.  I have a batch file that I'd like to run from an external HDD.  Here what is looks like...  FYI - the PAUSE statements were just put in there for troubleshooting...

@ECHO OFF
TITLE CLOSING MS-OUTLOOK

:::::::::::::::::::::::::::::::::::::::::::::::::
::REVISED: 15:03 07/24/2007
:::::::::::::::::::::::::::::::::::::::::::::::::

::Checking to see if ROBOCOPY.EXE exists
IF EXIST %SYSTEMROOT%\SYSTEM32\ROBOCOPY.EXE (GOTO START) ELSE (GOTO FAILED)

:START

::This will close Outlook for you since you can't backup the PST when it's locked.
%SYSTEMROOT%\SYSTEM32\TASKKILL.EXE /IM OUTLOOK.EXE /F /T

::Setting up variables for Robocopy only
SETLOCAL
SET DESK="%homepath%\Desktop"
SET DOCS="%homepath%\My Documents"
SET FAVS="%homepath%\Favorites"
SET SOURCE01="E:\Desktop"
SET SOURCE02="E:\Documents"
SET SOURCE03="E:\Favorites"
SET WHAT=/mir
SET OPTIONS=/R:2 /W:2
PAUSE

TITLE RUNNING THE RESTORE - DO NOT USE THE COMPUTER DURING THIS TIME!!
::Running the restore
robocopy %SOURCE01% %DESK% %WHAT% %OPTIONS%
PAUSE
robocopy %SOURCE02% %DOCS% %WHAT% %OPTIONS%
PAUSE
robocopy %SOURCE03% %FAVS% %WHAT% %OPTIONS%
PAUSE

::Unmounting the variables for Robocopy
ENDLOCAL

::Checks to see if the process ran properly.
IF %ERRORLEVEL% EQL 0 (GOTO COMPLETE)

:FAILED
ECHO Process failed!  Check your script or look for other issues.
PAUSE

:COMPLETE

Here's the issue...  If I run it from the desktop, it's fine.  If I run it from the external HDD, the destination ends up being the external HDD!  Which means it won't copy from the EHDD to %HomePath%\Desktop (or where ever...), it just creates the directory structure E:\Documents and Settings\User\Desktop on the EHDD and copies it there.

Any ideas?

Offline

#6 03 Aug 2007 19:23

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Problems with Robocopy in windows.

The first thing I'll say is that running taskkill against outlook is a quick way to end up with a corrupt pst file!

Are you running this under a different account/scheduled task - in that case the variable %HomePath% probably isn't being set

Try adding an Echo %DESK% before the first Pause and you'll see

Offline

#7 04 Aug 2007 18:18

rkillcrazy
Member
Registered: 03 Aug 2007
Posts: 6

Re: Problems with Robocopy in windows.

Simon Sheppard wrote:

The first thing I'll say is that running taskkill against outlook is a quick way to end up with a corrupt pst file!

Are you running this under a different account/scheduled task - in that case the variable %HomePath% probably isn't being set

Try adding an Echo %DESK% before the first Pause and you'll see

I've been using TASKKILL for a while now.  If there's a better/safer way, let me know...  This script was originally used for a scheduled backup.  That's why TASKKILL was used.  However, I modified it for use on a guy's laptop.

Although the original script was designed for SCHEDULED TASKS, I'm not running it as a scheduled task.  I was running it from the laptop.  Since it's not always on, I can't schedule it so I just drop a shortcut on the desktop and run it when I feel the need.

Offline

#8 06 Aug 2007 08:15

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Problems with Robocopy in windows.

Regarding an alternative to taskkill ... Since you say the script won't be running unattended, why not just put a check for "outlook.exe" in there and prompt the user to close it?  Something like this should do the trick (untested):

set i=0

:loop

tasklist | find /i "outlook.exe" >nul

set /a i+=1

if %errorlevel% EQU 0 (
    if %i% EQU 1 echo:Please close Outlook.
    ping 127.0.0.1 -n 2 >nul
    goto loop
)

As an aside, I'm pretty sure this line isn't going to work, since the correct comparison operator is "EQU":

IF %ERRORLEVEL% EQL 0 (GOTO COMPLETE)

cmd | *sh | ruby | chef

Offline

#9 08 Aug 2007 13:33

rkillcrazy
Member
Registered: 03 Aug 2007
Posts: 6

Re: Problems with Robocopy in windows.

Yes, you're right the EQL statement is a typo on my part....  I'll get that fixed up.

As for you loop script....
I'm having a hard time following what the commands are doing.  I've used the ping command to waste time before so that looks familiar.  I've obviously used goto commands before as well.  What else is going on here?  Furthermore, what if I did schedule it?  I have a similar script scheduled for myself that kills OUTLOOK.EXE and runs a backup nightly.  Although I've not had any issues, I don't want to play with fire...  So if there's a way to kill apps without corrupting data and schedule all of this to happen, by all means let me know.

08-08-07
0833 EDT

Offline

#10 10 Aug 2007 20:25

avery_larry
Member
Registered: 11 Jul 2007
Posts: 266

Re: Problems with Robocopy in windows.

rkillcrazy wrote:

As for you loop script....
I'm having a hard time following what the commands are doing.  I've used the ping command to waste time before so that looks familiar.  I've obviously used goto commands before as well.  What else is going on here?

tasklist | find /i "outlook.exe"
This line executes "tasklist", which lists all the running tasks, and then searches specifically for "outlook.exe" (not case sensitive).  If "outlook.exe" is found, then the find command will leave the errorlevel at 0.  If "outlook.exe" is NOT found, then find.exe will set errorlevel to 1.  (Of course, if outlook.exe is in the tasklist, then outlook is running.)

if %errorlevel% equ 0 (
This line checks the errorlevel.  If the errorlevel is 1, then outlook.exe isn't running and the whole if statement is skipped (and you continue on with your script).  If the errorlevel is 0, then outlook.exe is running and we execute the script:

if %i% EQU 1 echo:Please close Outlook.
This line, when combined with the previous set i=0 and set /a i+=1, is used to echo "Please close Outlook." only 1 time.  As part of the loop, the value of %i% continually increments by one, so the "if %a%" EQU 1" line is only true on the 1st pass through the loop.

ping ...
Just a way to pause 2 seconds before looping to re-check if outlook.exe is now closed.  The loop will continue until outlook.exe is no longer in the task list.

goto loop
this actually creates the loop.  Since it's inside the original if statement, we only loop if outlook is still running.

I would personally probably add a cls like this:

if %errorlevel% EQU 0 (
    if %i% EQU 1 (
        cls
        echo:Please close Outlook.
    )
    ping 127.0.0.1 -n 2 >nul
    goto loop
)

Or for me it would be simpler to do this:

:loop
tasklist | find /i "outlook.exe" >nul
if %errorlevel% EQU 0 (
    cls
    echo:Please close Outlook.
    ping 127.0.0.1 -n 2 >nul
    goto loop
)

instead of only displaying "Please close Outlook." once, I would cls and echo it every loop.

Offline

#11 12 Aug 2007 22:33

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Problems with Robocopy in windows.

Not tried it myself, but allegedly this will do it.  Not sure how well that'll work if Outlook prompts you about something, such as a Draft to keep/discard.

Easily found with Google. wink

Last edited by bluesxman (12 Aug 2007 22:39)


cmd | *sh | ruby | chef

Offline

#12 15 Aug 2007 14:52

rkillcrazy
Member
Registered: 03 Aug 2007
Posts: 6

Re: Problems with Robocopy in windows.

avery_larry wrote:
rkillcrazy wrote:

As for you loop script....
I'm having a hard time following what the commands are doing.  I've used the ping command to waste time before so that looks familiar.  I've obviously used goto commands before as well.  What else is going on here?

tasklist | find /i "outlook.exe"
This line executes "tasklist", which lists all the running tasks, and then searches specifically for "outlook.exe" (not case sensitive).  If "outlook.exe" is found, then the find command will leave the errorlevel at 0.  If "outlook.exe" is NOT found, then find.exe will set errorlevel to 1.  (Of course, if outlook.exe is in the tasklist, then outlook is running.)

if %errorlevel% equ 0 (
This line checks the errorlevel.  If the errorlevel is 1, then outlook.exe isn't running and the whole if statement is skipped (and you continue on with your script).  If the errorlevel is 0, then outlook.exe is running and we execute the script:

if %i% EQU 1 echo:Please close Outlook.
This line, when combined with the previous set i=0 and set /a i+=1, is used to echo "Please close Outlook." only 1 time.  As part of the loop, the value of %i% continually increments by one, so the "if %a%" EQU 1" line is only true on the 1st pass through the loop.

ping ...
Just a way to pause 2 seconds before looping to re-check if outlook.exe is now closed.  The loop will continue until outlook.exe is no longer in the task list.

goto loop
this actually creates the loop.  Since it's inside the original if statement, we only loop if outlook is still running.

I would personally probably add a cls like this:

if %errorlevel% EQU 0 (
    if %i% EQU 1 (
        cls
        echo:Please close Outlook.
    )
    ping 127.0.0.1 -n 2 >nul
    goto loop
)

Or for me it would be simpler to do this:

:loop
tasklist | find /i "outlook.exe" >nul
if %errorlevel% EQU 0 (
    cls
    echo:Please close Outlook.
    ping 127.0.0.1 -n 2 >nul
    goto loop
)

instead of only displaying "Please close Outlook." once, I would cls and echo it every loop.

Thanks for that...  I'll give that a try.  That should work for this guy's laptop.

Offline

#13 15 Aug 2007 14:55

rkillcrazy
Member
Registered: 03 Aug 2007
Posts: 6

Re: Problems with Robocopy in windows.

bluesxman wrote:

Not tried it myself, but allegedly this will do it.  Not sure how well that'll work if Outlook prompts you about something, such as a Draft to keep/discard.

Easily found with Google. wink

I liked the vbscript.  That was clean and effective for scheduling a backup.  I also found the little Command Line Process Viewer/Killer/Suspender
for Windows NT/2000/XP
and I'll play with that as well.

About this VB Script...
Does that look like a clean or graceful way of closing it?

Set objOLK = createObject("Outlook.Application")
objOLK.quit

Offline

#14 16 Aug 2007 21:36

rkillcrazy
Member
Registered: 03 Aug 2007
Posts: 6

Re: Problems with Robocopy in windows.

rkillcrazy wrote:
bluesxman wrote:

Not tried it myself, but allegedly this will do it.  Not sure how well that'll work if Outlook prompts you about something, such as a Draft to keep/discard.

Easily found with Google. wink

I liked the vbscript.  That was clean and effective for scheduling a backup.  I also found the little Command Line Process Viewer/Killer/Suspender
for Windows NT/2000/XP
and I'll play with that as well.

About this VB Script...
Does that look like a clean or graceful way of closing it?

Set objOLK = createObject("Outlook.Application")
objOLK.quit

UPDATE:
After speaking with a few coders in my office, I was told that this script is using the built-in controls in most Office apps.  Essentially, it's like clicking on FILE and clicking EXIT in Outlook.  This would suggest that it is a clean way of closing Outlook.  However, we still have not figured out why it gets confused when an external HDD is being used and the script it being ran from the EHDD...

Offline

Board footer

Powered by