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

Copying and Renaming - problem in VBScript

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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 44
Computer crashes, following error message in event manager 5 236
Adding to a VBA? 6 78
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 58
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…

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