Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



VB script does not run under scheduled task for mapped network drive

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 04-11-2009
JAW
 
Posts: n/a
VB script does not run under scheduled task for mapped network drive

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
Reply With Quote
  #2  
Old 05-11-2009
Pegasus [MVP]
 
Posts: n/a
Re: VB script does not run under scheduled task for mapped network drive


"JAW" <jwilliam@aglresources.com> wrote in message
news:f9c04786-aa9c-48de-8d65-121575e55cea@m38g2000yqd.googlegroups.com...
>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.


Reply With Quote
  #3  
Old 06-11-2009
jford
 
Posts: n/a
RE: VB script does not run under scheduled task for mapped network dri

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

"JAW" wrote:

> 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
> .
>

Reply With Quote
  #4  
Old 06-11-2009
Pegasus [MVP]
 
Posts: n/a
Re: VB script does not run under scheduled task for mapped network dri

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.


"jford" <jford@discussions.microsoft.com> wrote in message
news:F9FC7D52-CE94-487A-8F48-B9FEC59507E2@microsoft.com...
> 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
>
> "JAW" wrote:
>
>> 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
>> .
>>



Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "VB script does not run under scheduled task for mapped network drive"
Thread Thread Starter Forum Replies Last Post
Disconnect a network mapped drive in Windows XP Ebadaah Networking & Security 3 27-07-2009 02:20 PM
Problems accessing network drive folder with UNC & mapped drive Charles MacLean Small Business Server 2 10-06-2009 05:33 PM
Can't open mapped network drive zainladris Windows Vista Network 0 16-10-2008 07:12 PM
scheduled task can not access shared drive powdered_toast_man Window 2000 Help 13 04-06-2008 10:30 PM
Network Mapped Drive : Lost Network Connection Ian Robert Windows Vista Network 14 24-08-2007 04:28 PM


All times are GMT +5.5. The time now is 10:14 PM.