Solved

Does Set fs = Scripting.FileSystemObject work with Vista

Posted on 2009-04-15
6
731 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

The main issue when installing Vista and XP in dual boot is when you have to reinstall any of the two when something fails, let's say a hard disk failure, a lost partition, virus, etc. What commonly happens is that you lose all your hard work config…
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. …
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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