PDA

View Full Version : get path from registry and use it elsewhere



jeanh2
04-01-2004, 10:47 AM
I want to get a path from the registry and use it to create a folder in the destination computer because I have to install some files there. It is not the [INSTALLDIR]. How can I do that?

Alfaromeo
04-02-2004, 12:18 AM
Hi jean2

I have created custom action vbscript which gets the path from the registry and creates a folder in the specified path.

I have invoked the custom action After Install Welcome Dialog.

The code for the same is as follows

set WshShell=CreateObject("WScript.Shell")

regValue = WshShell.RegRead("HKCU\Path\Path")

CreateFOlders(regvalue)

Sub CreateFolders(strPath)

Dim objFso
Dim arrFolders
Dim strDrive
Dim strFolder
Set objFso = CreateObject("Scripting.FileSystemObject")
' Format path (remove leading and trailing spaces, and final backslash)
strPath = Trim(strPath)
If Right(strPath, 1) = "\" Then
strPath = Left(strPath, Len(strPath) - 1)
End If
' Check that a drive is specified and that it exists (if not, exit sub)
If Mid(strPath, 2, 2) <> ":\" Then
WScript.Echo "The path specified is invalid."
Exit Sub
Else
strDrive = Left(strPath, 1)
If Not objFso.DriveExists(strDrive) Then
WScript.Echo "The drive specified does not exist."
Exit Sub
End If
End If
' Split the path into an array, first element is the drive, subsequent elements are the folders
arrFolders = Split(strPath, "\")
' Build the path, folder by folder. If folder doesn't exist, create it
strFolder = arrFolders(0)
For i = LBound(arrFolders) To UBound(arrFolders) - 1
strFolder = strFolder & "\" & arrFolders(i+1)
If Not objFso.FolderExists(strFolder) Then
objFso.CreateFolder(strFolder)
End If
Next

End Sub

Hope it helps

Reagrds
Alfaromeo

NCSLASC
04-02-2004, 07:21 AM
Hi,

you can use regedit /e and export the key that you need to a file a read it.