用VBScript分享資料夾
作者: fase 日期: 2010-04-27 11:57
有時軟體在製作安裝程式時
如果只是基本的安裝
是不需要什麼特別的設定
但複雜的安裝時
就需要一些自訂的程序幫忙安裝
通常我都是利用VBScript
只要安裝程式軟體有支援VBScript
則就可以利用VBScript來作特殊的應用
這邊是說明用VBScript來分享資料夾
本文是參考
http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/filesfolders/sharedfolders/
分享資料夾C:\Finance,分享名稱FinanceShare
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 255
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & " ootcimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create ("C:\Finance", "FinanceShare", FILE_SHARE, MAXIMUM_CONNECTIONS, "Public share for the Finance group.")
取消分享FinanceShare
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & " ootcimv2")
Set colShares = objWMIService.ExecQuery _
("Select * from Win32_Share Where Name = 'FinanceShare'")
For Each objShare in colShares
objShare.Delete
Next
給需要的人參考,也給自己作記錄
如果只是基本的安裝
是不需要什麼特別的設定
但複雜的安裝時
就需要一些自訂的程序幫忙安裝
通常我都是利用VBScript
只要安裝程式軟體有支援VBScript
則就可以利用VBScript來作特殊的應用
這邊是說明用VBScript來分享資料夾
本文是參考
http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/filesfolders/sharedfolders/
分享資料夾C:\Finance,分享名稱FinanceShare
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 255
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & " ootcimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create ("C:\Finance", "FinanceShare", FILE_SHARE, MAXIMUM_CONNECTIONS, "Public share for the Finance group.")
取消分享FinanceShare
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & " ootcimv2")
Set colShares = objWMIService.ExecQuery _
("Select * from Win32_Share Where Name = 'FinanceShare'")
For Each objShare in colShares
objShare.Delete
Next
給需要的人參考,也給自己作記錄
評論: 0 |
引用: 0 |
閱讀: 3543 |
回到頁首