Discussion:
VB script does not run under scheduled task for mapped network drive
(too old to reply)
JAW
2009-11-04 18:02:13 UTC
Permalink
I have a script that at the end must copy a file from one server to
another server.

I mapped a network drive via NET USE and saved the credentials and it
works great!

However, when I run the job (using the same account) as a scheduled
task the copy fails. It works fine on a local drive but not on a
networked driver. I get a 76 return code from the the copy.

Below is the area of the code that fails.

' FTP good backup copy and check for success

Const OverwriteExisting = TRUE
objFSO.CopyFile v_backup,v_xbackup,OverwriteExisting
objFSO.CopyFile v_output,v_xoutput,OverwriteExisting

v_returncode = err.number

If v_Returncode = 0 then
WScript.echo "FTP return code =" & v_ReturnCode
Else
WScript.echo "FTP return code =" & v_ReturnCode
WScript.echo "FTP command errored out"
Call emailer
v_msg = "Process Completed: " & time
WScript.Echo v_msg
Wscript.Quit 1
End If
Pegasus [MVP]
2009-11-04 19:01:59 UTC
Permalink
Post by JAW
I have a script that at the end must copy a file from one server to
another server.
I mapped a network drive via NET USE and saved the credentials and it
works great!
However, when I run the job (using the same account) as a scheduled
task the copy fails. It works fine on a local drive but not on a
networked driver. I get a 76 return code from the the copy.
Below is the area of the code that fails.
' FTP good backup copy and check for success
Const OverwriteExisting = TRUE
objFSO.CopyFile v_backup,v_xbackup,OverwriteExisting
objFSO.CopyFile v_output,v_xoutput,OverwriteExisting
v_returncode = err.number
If v_Returncode = 0 then
WScript.echo "FTP return code =" & v_ReturnCode
Else
WScript.echo "FTP return code =" & v_ReturnCode
WScript.echo "FTP command errored out"
Call emailer
v_msg = "Process Completed: " & time
WScript.Echo v_msg
Wscript.Quit 1
End If
Make sure to use UNC paths in scheduled jobs. Mapped drives do NOT exist in
scheduled jobs, unless you explicitly map them, and even then they could
fail for a number of reasons.
jford
2009-11-06 13:02:01 UTC
Permalink
It works, but possibly Pegasus can correct my bad scripting habits

@echo off

set loc1="C:\Program Files\Microsoft Office\Office11\OIS.exe"
set loc2="C:\Program Files\Microsoft Office\Office12\OIS.exe"
set loc3="C:\program files\Microsoft Office\ART\Office12\OIS.exe"

if exist %loc1% (
call :regadd %loc1%
)
if exist %loc2% (
call :regadd %loc2%
)
if exist %loc3% (
call :regadd %loc3%
)
goto end
:regadd
reg add <keyname> /v <valuename> /d %1
:end
Post by JAW
I have a script that at the end must copy a file from one server to
another server.
I mapped a network drive via NET USE and saved the credentials and it
works great!
However, when I run the job (using the same account) as a scheduled
task the copy fails. It works fine on a local drive but not on a
networked driver. I get a 76 return code from the the copy.
Below is the area of the code that fails.
' FTP good backup copy and check for success
Const OverwriteExisting = TRUE
objFSO.CopyFile v_backup,v_xbackup,OverwriteExisting
objFSO.CopyFile v_output,v_xoutput,OverwriteExisting
v_returncode = err.number
If v_Returncode = 0 then
WScript.echo "FTP return code =" & v_ReturnCode
Else
WScript.echo "FTP return code =" & v_ReturnCode
WScript.echo "FTP command errored out"
Call emailer
v_msg = "Process Completed: " & time
WScript.Echo v_msg
Wscript.Quit 1
End If
.
Pegasus [MVP]
2009-11-06 13:30:56 UTC
Permalink
The OP's post dealt with the question of using a scheduled task to copy some
files from here to there. Your response deals with a registry hack. I am
unable to see any connection between the two.
Post by jford
It works, but possibly Pegasus can correct my bad scripting habits
@echo off
set loc1="C:\Program Files\Microsoft Office\Office11\OIS.exe"
set loc2="C:\Program Files\Microsoft Office\Office12\OIS.exe"
set loc3="C:\program files\Microsoft Office\ART\Office12\OIS.exe"
if exist %loc1% (
call :regadd %loc1%
)
if exist %loc2% (
call :regadd %loc2%
)
if exist %loc3% (
call :regadd %loc3%
)
goto end
:regadd
reg add <keyname> /v <valuename> /d %1
:end
Post by JAW
I have a script that at the end must copy a file from one server to
another server.
I mapped a network drive via NET USE and saved the credentials and it
works great!
However, when I run the job (using the same account) as a scheduled
task the copy fails. It works fine on a local drive but not on a
networked driver. I get a 76 return code from the the copy.
Below is the area of the code that fails.
' FTP good backup copy and check for success
Const OverwriteExisting = TRUE
objFSO.CopyFile v_backup,v_xbackup,OverwriteExisting
objFSO.CopyFile v_output,v_xoutput,OverwriteExisting
v_returncode = err.number
If v_Returncode = 0 then
WScript.echo "FTP return code =" & v_ReturnCode
Else
WScript.echo "FTP return code =" & v_ReturnCode
WScript.echo "FTP command errored out"
Call emailer
v_msg = "Process Completed: " & time
WScript.Echo v_msg
Wscript.Quit 1
End If
.
Loading...