Solved

Does Set fs = Scripting.FileSystemObject work with Vista

Posted on 2009-04-15
6
727 Views
Last Modified: 2012-08-14
I get an error mesage that the object does not exist on a Vista pc when I use:

Set fs = CreateObject("Scripting.FileSystemObject")
If fs.folderexists(rsSpecs!ShortcutPathVista) Then
This works splendidly on XP pcs.
...
0
Comment
Question by:paulmcneil
  • 4
6 Comments
 
LVL 10

Expert Comment

by:TakedaT
ID: 24148738
im running vista 32 and it works just fine for me
0
 
LVL 10

Expert Comment

by:TakedaT
ID: 24149666
try this
start-->run-->regsvr32 scrrun.dll
then try your script again
0
 

Author Comment

by:paulmcneil
ID: 24150089
TakedaT,
Thanks for responding. Would you try this code?
Dim fs As Object
Dim strSource As String
Dim strTarget As String

Set fs = CreateObject("Scripting.FileSystemObject")

If fs.folderExists("C:\users\public") = False Then
  msgbox "C:\users\public exists"
End If
     
If fs.FileExists(SOME PATH AND FILE ON YOUR VISTA PC THAT YOU CAN DELETE) = True Then
  fs.deletefile (SOME PATH AND FILE ON YOUR VISTA PC THAT YOU CAN DELETE)
End If

If fs.FileExists(SOME ShortCut PATH AND FILE ON YOUR VISTA PC THAT YOU CAN DELETE - a .lnk file) = True Then
  fs.deletefile (SOME ShortCut PATH AND FILE ON YOUR VISTA PC THAT YOU CAN DELETE - a .lnk file)
End If

strSource = SOME PATH AND FILE YOU CAN COPY
strTarget = SOME PATH AND FILE YOU CAN COPY TO

fs.CopyFile strSource, strTarget, True
0
 
LVL 10

Accepted Solution

by:
TakedaT earned 500 total points
ID: 24150779
The following code worked just fine for me.  I removed the "as object" and "as string" though, as my pc didnt like it.  The if statement at the 5th line has a "false" that Im assuming you meant to be  a "true".  In the case here, the echo didnt happen as because the folder does in fact exist.  It deleted the existing files and copied the copyme file to the copied file.

What errors are you getting?
Dim fs

Dim strSource

Dim strTarget
 

Set fs = CreateObject("Scripting.FileSystemObject")
 

If fs.folderExists("C:\users\public") = False Then

  msgbox "C:\users\public exists"

End If

      

If fs.FileExists("C:\test\test.txt") = True Then

  fs.deletefile ("C:\test\test.txt")

End If
 

If fs.FileExists("C:\test\autoexec.lnk") = True Then

  fs.deletefile ("C:\test\autoexec.lnk")

End If
 

strSource = "c:\test\copyme.txt"

strTarget = "c:\test\copied.txt"
 

fs.CopyFile strSource, strTarget, True

Open in new window

0
 
LVL 10

Expert Comment

by:TakedaT
ID: 24150791
I meant in the 7th line, not the 5th line.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Hi All Just a quick one for everybody. I was recently looking into setting the default User Account Picture for all my vista clients within the network but on closer inspection the group policy setting only allows you to set the default pictur…
So who is this article for? If you are like most of the computer users out there, you probably only realize the meaning of 'System maintenance' after something goes wrong. This article is for you if you care about keeping your system working opti…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now