Schedule Task xcopy

  • Thread starter Thread starter humbleFunGuy
  • Start date Start date
H

humbleFunGuy

OS: Windows 2000 server

I am trying to use run XCOPY or xxcopy from my script using schedule
task. The script works fine on the command line but when I run from
the schedule task it does not do anything. The task executes and stops
without any erros.

I am trying to mirror between two folders on networked shared drives.

Set objShell = CreateObject("WScript.Shell")
'map network drive.

objShell.Run("net use j: \\server1\sourceShare /USER:user1 password"),
1, yes

objShell.Run("net use k: \\server2\targetShare /USER:user1 password"),
1, yes

objSehll.Run("mirror j:\source k:\target"), 1, yes


In schedule task this does not do anything, just returns Last
Result=0x0. However, if I run this on the command-line it executes and
works fine.

I know there some issue with context in which each share happens. But
I am not sure how to fix this. Any help is appreciated.

Thanks,
irfan
(e-mail address removed)
 
OS: Windows 2000 server

I am trying to use run XCOPY or xxcopy from my script using schedule
task. The script works fine on the command line but when I run from
the schedule task it does not do anything. The task executes and stops
without any erros.

I am trying to mirror between two folders on networked shared drives.

Set objShell = CreateObject("WScript.Shell")
'map network drive.

objShell.Run("net use j: \\server1\sourceShare /USER:user1 password"),
1, yes

objShell.Run("net use k: \\server2\targetShare /USER:user1 password"),
1, yes

objSehll.Run("mirror j:\source k:\target"), 1, yes


In schedule task this does not do anything, just returns Last
Result=0x0. However, if I run this on the command-line it executes and
works fine.

I know there some issue with context in which each share happens. But
I am not sure how to fix this. Any help is appreciated.

Assuming by "yes" you mean the boolean "true" (=wait for RUN
process to complete), try the standard syntax:

objShell.Run("net use k: \\server2\targetShare /USER:user1 password", 1, true)

and so on for the other lines. Also be sure to spell your variables consistently,
and _not_ as in:
objSehll.Run("mirror

It's worthwhile using Option Explicit and declaring all variables properly.
 
Hello, humbleFunGuy:
On 27 Aug 2005 10:21:20 -0700: you wrote...

h> OS: Windows 2000 server

Try something like this:
x = objShell.Run("net use j: \\server1\sourceShare /USER:user1 password"),
msgbox x
x will be the return value of the net use command. You may also want to
throw in a wscript.sleep 10000 to give the machine a chance to mount the
share.

Don't know if either will help but you'll see what net use returns. You may
even want to use the exec method and capture the standout and stderr streams
to see if they tell you anything.

Regards, Paul R. Sadowski [MVP].
 
Basically an answer to this anonymous coward I don't see...
"humbleFunGuy" wrote in message

Very funny to encapsulate a 3-line .BAT or .CMD in a VBScript!
I suggest to strip the whole VBScript and use plain old CMD.EXE only, or
use VBScript's methods, as in:

objNet = CreateObject("WScript.Network")
objNet.MapNetworkDrive(...)

Which credentials does the scheduled task run under?
What command line is used for the scheduled task?
What's this "mirror" command? An executable found in %PATH%?

Always use the complete pathname if available: "%SystemRoot%\System32\Net.Exe"
instead of just "net". Don't rely on %PATH%, and don't open security holes.
Remember that . is always the first (implicit) component in %PATH%!
Assuming by "yes" you mean the boolean "true" (=wait for RUN
process to complete), try the standard syntax:

objShell.Run("net use k: \\server2\targetShare /USER:user1 password", 1, true)

and so on for the other lines. Also be sure to spell your variables consistently,
and _not_ as in:


It's worthwhile using Option Explicit and declaring all variables properly.

A "%SystemRoot%\SYSTEM32\NET.EXE USE" might be useful too before "mirror"!

Stefan
 
Back
Top