Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBS to share a folder on multiple servers

$
0
0

Hi

I used the following script to share a folder on multiple servers.....

INPUT_FILE_NAME = "C:\temp\Computers.txt"Const FILE_SHARE = 0 Const MAXIMUM_CONNECTIONS = 25 Const FOR_READING = 1Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
strComputers = objFile.ReadAll
objFile.Close
arrComputers = Split(strComputers, vbCrLf)ForEach strComputer In arrComputersSet objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\"& strComputers & "\root\cimv2")Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create _
    ("C:\tas", "TAS", FILE_SHARE, _
        MAXIMUM_CONNECTIONS, "Public share for the Finance group.")
Wscript.Echo errReturnnext

This works fine when i have only 1 server in the input text file but when i add more i receive the following error......

Error: The remote server machine does not exist or is unavailable: 'GetObject'
Code: 800A01CE
Source: Microsoft VBScript Runtime Error

I have a similar script that works fine to create folders using the same text input file.  Any ideas?

Thanks


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>