Computing.Net > Forums > Programming > vb script file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

vb script file

Reply to Message Icon

Name: noodyblum
Date: December 4, 2006 at 04:48:51 Pacific
OS: windows 2003 server
CPU/Ram: 2 gig
Product: compaq
Comment:

Hi

I am trying to run the following vbscript file as a windows scheduled task.

The job launches but does not doing any copying.

dim sourcePath
dim targetPath
dim fso
dim f
sourcePath = "C:\Program Files\Software AG\Natural\Natapps\Fuser\*"
targetPath = "E:\natural backups\"
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.copy (sourcePath ,targetPath)

Help ???

Noody



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: December 5, 2006 at 09:04:28 Pacific
Reply:

I dunno VBS but it LOOKS LIKE that script sets vars and does nothing else. So I suppose if it's to do some copying, it needs more code.


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: Michael J (by mjdamato)
Date: December 5, 2006 at 13:49:24 Pacific
Reply:

No, the problem is that you are using just "copy" which requires an OBJECT. You should use copyfolder.

However although the paths you have above should work, thy did not work in my testing. Your best bet is to use this (notice no / at the end of source):
========BEGIN CODE=========
Dim sourcePath, targetPath, overwrite, fso

sourcePath = "C:\Program Files\Software AG\Natural\Natapps\Fuser"
targetPath = "E:\natural backups\"
overwrite = true

Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FolderExists(sourcePath) Then
fso.CopyFolder sourcePath, targetPath
End If
========END CODE=========

However that will copy the source folder and it's contents to the destination, not just the contents of the source.

Michael J


0

Response Number 3
Name: noodyblum
Date: December 6, 2006 at 00:43:15 Pacific
Reply:

Hi Michael

I did exactly what you said before reading your reply and it works like a charm.

Thanks anyway for the response.

Noody


0

Response Number 4
Name: tonysathre
Date: December 6, 2006 at 16:05:58 Pacific
Reply:

Why not just use a batch file?

@echo off

echo Backup Started
echo.
xcopy /y /q "C:\Program Files\Software AG\Natural\Natapps\Fuser" "E:\natural backups\" > nul
echo Backup Complete
pause

To schedule this to run everynight at 10:00 PM run this command:

at 22:00 /every:m,t,w,th,f,s,su "C:\path\to\script\backup.bat"

"Computer security." — Oxymoron


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: vb script file

VBS script to delete files www.computing.net/answers/programming/vbs-script-to-delete-files/14805.html

VB Script needed to Copy files www.computing.net/answers/programming/vb-script-needed-to-copy-files/14942.html

VB Script for deleting files www.computing.net/answers/programming/vb-script-for-deleting-files-/16904.html