Regarding VBScript for Custom Action
[left][font="courier new"]How should i write a script if I want to replace "abc" to "pqr" and my path is [/left][left] C:\Program Files\Common files\XYZ\abc\[/left][left] [/left][left]which is my Destination folder in Installshield i.e where my binaries will go . Want to write a custom action in vbscript . So how should i proceed?[/left]
0 Comments
[ + ] Show comments
Answers (6)
Please log in to answer
Posted by:
anonymous_9363
16 years ago
What are you trying to achieve? It's not clear if you want to change the destination folder in your InstallShield project or on the target workstation. If the former, just edit the relevant 'Directory' table entry. If the latter, you would use the FileSystemObject object's MoveFolder method to rename the folder. There are a gazillion examples on the web. Here's a simple one http://activexperts.com/activmonitor/windowsmanagement/adminscripts/filesfolders/folders/#RenameFolder.htm If it were me, I'd add lots of error-trapping to this code but YMMV.
Posted by:
yshariff
16 years ago
Hello,
As per my knowledge,there is no option in VB Script of Replacing a file or folder, however you can delete the existing folder and create a new folder in its place and get your contents written to that folder.
On Error Resume Next
Set fso = CreateObject("Scripting.FilesSystemObject")
if fso.FolderExists ("C:\Program Files\Common files\XYZ\abc") Then
fso.DeleteFolder "C:\Program Files\Common files\XYZ\abc"
fso.CreateFolder "C:\Program Files\Common files\XYZ\pqr\
end If
As per my knowledge,there is no option in VB Script of Replacing a file or folder, however you can delete the existing folder and create a new folder in its place and get your contents written to that folder.
On Error Resume Next
Set fso = CreateObject("Scripting.FilesSystemObject")
fso.DeleteFolder "C:\Program Files\Common files\XYZ\abc"
fso.CreateFolder "C:\Program Files\Common files\XYZ\pqr\
Posted by:
vilobh_meshram
16 years ago
I would Clarify my question . In Installshield , in the Property table under Direct Editor I have a propety with name "Consumer" who's value is "VM" now when I use this property in setting the registry value it gets reflected correctly i.e
HKLM\SOFTWARE\[Consumer]\ gets replaced to HKLM\SOFTWARE\VM but the Destination where the binaries will go i.e the Destination Directory is not getting the value i.e when I use C:\Program Files\Common Files\[Consumer]\abc
is not getting replaced with C:\Program Files\Common Files\VM\abc which I want.It shows as C:\Program Files\Common Files\[Consumer]\abc i.e "[Consumer]" thing. so now I want to replace this "[Consumer]" thing from the Destination Directory path and replcae it with the value which i have set in the Property table . How should I got about writing a Custom action in vbscript for this as I being a newbie in this area ????
HKLM\SOFTWARE\[Consumer]\ gets replaced to HKLM\SOFTWARE\VM but the Destination where the binaries will go i.e the Destination Directory is not getting the value i.e when I use C:\Program Files\Common Files\[Consumer]\abc
is not getting replaced with C:\Program Files\Common Files\VM\abc which I want.It shows as C:\Program Files\Common Files\[Consumer]\abc i.e "[Consumer]" thing. so now I want to replace this "[Consumer]" thing from the Destination Directory path and replcae it with the value which i have set in the Property table . How should I got about writing a Custom action in vbscript for this as I being a newbie in this area ????
Posted by:
aogilmor
16 years ago
[align=left][font="courier new"]How should i write a script if I want to replace "abc" to "pqr" and my path is [/align][align=left] C:\Program Files\Common files\XYZ\abc\[/align][align=left]which is my Destination folder in Installshield i.e where my binaries will go . Want to write a custom action in vbscript . So how should i proceed?[/align]
No time to read all the responses but I think Ian alluded to editing the Directory table. First you should find out what directory table entry corresponds to
C:\Program Files\Common Files\\abc and why the vm is not getting in there. Look in the directory table and see if there's an entry for
C:\Program Files\Common Files\vm\abc. If there is, you can use that directory name as a property in your reg value.
Posted by:
AngelD
16 years ago
Posted by:
anonymous_9363
16 years ago
ORIGINAL: vilobh_meshramGot it, I think.
the Destination where the binaries will go i.e the Destination Directory is not getting the value i.e when I use C:\Program Files\Common Files\[Consumer]\abc is not getting replaced with C:\Program Files\Common Files\VM\abc which I want.It shows as C:\Program Files\Common Files\[Consumer]\abc i.e "[Consumer]" thing.
Owen (aogilmor) is on the right track. It's bad practice to use single properties in paths in the way you have done.
Look in your projects 'Directory' table and find the directory name which corresponds to 'C:\Program Files\Common Files\VM\ABC'. If I know the two major authoring tools, that Directory which be called 'ABC'. Use that directory name, i.e. 'ABC' as the property. Thus, instead of using
C:\Program Files\Common Files\[Consumer]\abc
use
[abc]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.