?
Solved

Does Set fs = Scripting.FileSystemObject work with Vista

Posted on 2009-04-15
6
Medium Priority
?
734 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Service applet starts in Extended Mode by Default, with a taskpad on the left of the services pane. This view mode was introduced in XP. As I find it not very usefull, I like to use the Standard view as default, and without the Console tree. …
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…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 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