?
Solved

Copying and Renaming - problem in VBScript

Posted on 2004-09-13
4
Medium Priority
?
156 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
[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
  • 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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