Solved

Copying and Renaming - problem in VBScript

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

690 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