Solved

Copying and Renaming - problem in VBScript

Posted on 2004-09-13
4
150 Views
Last Modified: 2010-05-02
Hi

I am trying to write a .vbs file to migrate files from one server to another. So the paths of the files would be \\Server1Name\Somefolder to \\Server2Name\Someotherfolder.

How do I get the full paths of these folders if I have to dynamically select them using BrowseForFolder? The problem is that this method only gives me the title of the folder I selected. It does not trecord the path. Is there a workaround to this? or an alternate solution?

Thanks in advance

Prasad
0
Comment
Question by:PrasadViswanathan
  • 2
4 Comments
 
LVL 9

Expert Comment

by:samopal
ID: 12049483
Add reference to MS Shell Controls

Dim oShell As New Shell
Dim oFolder As Folder
Dim oFolderItem As FolderItem
 
  Set oFolder = oShell.BrowseForFolder(Me.hWnd, "Select a Folder",  0, ssfDrives)
   
Set oFolderItem = oFolder.Items.Item
Debug.Print oFolderItem.Path

Hope This Helps,
D'Al
0
 

Author Comment

by:PrasadViswanathan
ID: 12049739
hi samopal,

Thanks for the quick reply. But this doesn't work for me :(. Maybe I need to tweak it a bit....
0
 
LVL 3

Accepted Solution

by:
domj earned 250 total points
ID: 12050021
You have to create the Shell object in scripting. This should work for you!

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.BrowseForFolder(0, "Select Folder", 0, 0)

if not (objFolder is Nothing) then
      set objFolItem=objFolder.Items.Item
      MsgBox objFolItem.Path
end if
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let me know how you go.

Dom
0
 

Author Comment

by:PrasadViswanathan
ID: 12059063
Thanks Dom,

I used your script and it works perfectly
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 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

15 Experts available now in Live!

Get 1:1 Help Now