Search code examples
cmdvbscriptinstallationinstallshield

Sharing INSTALLDIR windows folder in InstallShield


I want to share my setup directory in installshield. I did some search and found a VB Script and a CMD Command:

      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, "MyShare"

cmd command:

net share sharename=[INSTALLDIR]

When i run VBScript i don't see any error but I can't share my folder. When i run cmd command, command can't share because it requires admin privilege; but I am not sure, how i can provide admin privilege to it; can i share folder? how?


Solution

  • Try. You need to have access rights on location that you are trying to share.

    net share Share=E:\Shared /Grant:Everyone,full
    

    Note: You can change the share rights based on your need. This is strictly an example.