Solved

Copying and Renaming - problem in VBScript

Posted on 2004-09-13
4
152 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 42
VBA filters 2 59
Automatic Email Reminder 4 36
Publisher:   Unknown     VB.exe Application 1 17
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 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

13 Experts available now in Live!

Get 1:1 Help Now