Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Does Set fs = Scripting.FileSystemObject work with Vista

Posted on 2009-04-15
6
Medium Priority
?
735 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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