This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Share INSTALLDIR folder
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 17, 2009
09:11 AM
Share INSTALLDIR folder
Is it posible to share a INSTALLDIR folder prior or after the installation?
Thank you for your help.
Thank you for your help.
(9) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2009
06:10 AM
Nejchy wrote:
Is it posible to share a INSTALLDIR folder prior or after the installation?
Thank you for your help.
Maybe i wasn't clear enough.
I want to create a Windows folder share, so that it will be visible to other computer across the network.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2009
07:25 AM
You can't do it through the tables but you can do it via a custom action.
You can run this vbscript as a deferred custom action:
Option Explicit
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25
Dim objShare
'Connect to WMI
Dim objWMIService: Set objWMIService = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
'Query share names for existing share
Dim colShares: Set colShares = objWMIService.ExecQuery _
("Select * from Win32_Share Where Name = 'MyShare'")
'Delete share if one exists with the same name already
For Each objShare in colShares
objShare.Delete
Next
'Create new share
Dim objNewShare: Set objNewShare = objWMIService.Get("Win32_Share")
Dim strFilePath: strFilePath = Session.Property("CustomActionData")
strFilePath = Left(strFilePath, Len(strFilePath) - 1)
objNewShare.Create strFilePath, "'MyShare'", _
FILE_SHARE, MAXIMUM_CONNECTIONS, "My shared folder description"
You then create an immediate execute custom action to set a property. You can call it anything you like but the property you are setting needs to be the name of the custom action you created with the script. The value needs to be the folder you are sharing. E.g. [INSTALLDIR]
Hope this helps
You can run this vbscript as a deferred custom action:
Option Explicit
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25
Dim objShare
'Connect to WMI
Dim objWMIService: Set objWMIService = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
'Query share names for existing share
Dim colShares: Set colShares = objWMIService.ExecQuery _
("Select * from Win32_Share Where Name = 'MyShare'")
'Delete share if one exists with the same name already
For Each objShare in colShares
objShare.Delete
Next
'Create new share
Dim objNewShare: Set objNewShare = objWMIService.Get("Win32_Share")
Dim strFilePath: strFilePath = Session.Property("CustomActionData")
strFilePath = Left(strFilePath, Len(strFilePath) - 1)
objNewShare.Create strFilePath, "'MyShare'", _
FILE_SHARE, MAXIMUM_CONNECTIONS, "My shared folder description"
You then create an immediate execute custom action to set a property. You can call it anything you like but the property you are setting needs to be the name of the custom action you created with the script. The value needs to be the folder you are sharing. E.g. [INSTALLDIR]
Hope this helps
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 21, 2009
03:13 AM
Thank for the answer. I'm sure the script works, but i have problems setting it.
Could you confirm that what i'm doing is right?
I created a new vbscript custom action stored in custom action.
It's name is NewCustomAction. I also set in-script execution to deferred.
Then i created new custom action set property. It's name is NewProperty.
Property name:shareProperty
Property value:[INSTALLDIR]
Then i changed Session.Property("CustomActionData") to Session.Property("shareProperty") and also added parenthesis to the
objNewShare.Create(strFilePath, "'MyShare'", _
FILE_SHARE, MAXIMUM_CONNECTIONS, "My shared folder description")
But as i'm a complete beginner i don't know when or in which order to call these two custom actions.
Now i'm first calling NewProperty in Install Exec Sequence after ScheduleReboot and NewCustomAction after NewProperty.
When i run this i get: Error 1720.
What did i do wrong?
Thanks for your help.
Could you confirm that what i'm doing is right?
I created a new vbscript custom action stored in custom action.
It's name is NewCustomAction. I also set in-script execution to deferred.
Then i created new custom action set property. It's name is NewProperty.
Property name:shareProperty
Property value:[INSTALLDIR]
Then i changed Session.Property("CustomActionData") to Session.Property("shareProperty") and also added parenthesis to the
objNewShare.Create(strFilePath, "'MyShare'", _
FILE_SHARE, MAXIMUM_CONNECTIONS, "My shared folder description")
But as i'm a complete beginner i don't know when or in which order to call these two custom actions.
Now i'm first calling NewProperty in Install Exec Sequence after ScheduleReboot and NewCustomAction after NewProperty.
When i run this i get: Error 1720.
What did i do wrong?
Thanks for your help.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 21, 2009
03:49 AM
Option Explicit
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25
Dim objShare
'Connect to WMI
Dim objWMIService: Set objWMIService = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
'Query share names for existing share
Dim colShares: Set colShares = objWMIService.ExecQuery _
("Select * from Win32_Share Where Name = 'MyShare'")
'Delete share if one exists with the same name already
For Each objShare in colShares
objShare.Delete
Next
'Create new share
Dim objNewShare: Set objNewShare = objWMIService.Get("Win32_Share")
Dim strFilePath: strFilePath = Session.Property("shareProperty")
strFilePath = Left(strFilePath, Len(strFilePath) - 1)
objNewShare.Create strFilePath, "'MyShare'", _
FILE_SHARE, MAXIMUM_CONNECTIONS, "My shared folder description"
I just found that there is a problem with the Left method.
The error is invalid procedure call or argument:'Left'
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 21, 2009
04:26 AM
Ok I can see what went wrong. The problem with deferred custom actions is that you don't get access to properties using the Session.Property method easily. So the solution i gave you is a well known tip on getting properties into deferred custom actions. So where you went wrong is this:
The property name you are changing should not be shareProperty it should be the name of the script custom action so you are setting the property name NewCustomAction instead (matches the name of your customaction called NewCustomAction). When you set a property with the same name as the custom action you can refer to it in the scripts as Session.Property("CustomActionData") so you will need to put the script back to using this.
The reason the Left didn't work is because it was trying to work out the left on a null value because it can't access your property shareProperty directly in deferred mode.
As for sequencing I tend to put the set property action just before costfinalize and then you can set the script custom action anywhere you like between installinitialize and installfinalize.
Hope this helps 🙂
The property name you are changing should not be shareProperty it should be the name of the script custom action so you are setting the property name NewCustomAction instead (matches the name of your customaction called NewCustomAction). When you set a property with the same name as the custom action you can refer to it in the scripts as Session.Property("CustomActionData") so you will need to put the script back to using this.
The reason the Left didn't work is because it was trying to work out the left on a null value because it can't access your property shareProperty directly in deferred mode.
As for sequencing I tend to put the set property action just before costfinalize and then you can set the script custom action anywhere you like between installinitialize and installfinalize.
Hope this helps 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 21, 2009
06:31 AM
It works.
Thank you.
Thank you.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 12, 2011
04:17 AM
Thank you so much for this thread, I have just got this working (InstallShield 2011).
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 10, 2011
10:10 AM
Is there a way to do this in an InstallScript project as well?
The documentation suggests that this solution only works with Basic MSI or InstallScript MSI.
The documentation suggests that this solution only works with Basic MSI or InstallScript MSI.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 09, 2011
01:35 AM
hi
i have problem and i need to help you
i do this action but no folder become share!!!! i do not have error
please help me. i need it
😞
i have problem and i need to help you
i do this action but no folder become share!!!! i do not have error
please help me. i need it
😞