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
Solved

Does Set fs = Scripting.FileSystemObject work with Vista

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Office 2010 Pro Plus crashing 5 321
HELP!! Hard Drive Issues 21 362
Snap-do keeps coming back 3 513
Vista background will not stick 7 252
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…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
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…

856 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