I'm trying to run a script that prompts a user for a location and once that location has been selected, the script will copy IE favorites to that location .(It's part of a bigger project to copy multiple directories to a location of your choice)
It starts off with a VBS script to create the prompt, then I create a variable based on what's selected. Then the script copies IE favorites to that selected location. The problem is, if I select "cancel" the script runs anyway!
Any help is much appreciated!
Code: (Batch Script)
@echo off
For /F "Tokens=1 Delims=" %%I In ('cscript //nologo BrowseFolder.vbs') Do Set _FolderName=%%I
set dest=%_FolderName%
md "%dest%\UserBackup" &md "%dest%\UserBackup\Favorites" &ROBOCOPY /E /XJ "%userprofile%\Favorites" "%dest%\UserBackup\Favorites"
Code: (VBS Script) - Save as "BrowseFolder.vbs"If you want to run it as an example.
Const MY_COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Please select the destination for your data:", OPTIONS, strPath)
If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
Wscript.Echo objPath
Thank you in advance!