Jump to content

Creating an Network Share


Recommended Posts

I did find this code in a topic, but I get the error that:

Variable must be of type "Object".:

$objNewShare = $objWMIService.Get("Win32_Share")

$objNewShare = $objWMIService^ ERROR

Const $FILE_SHARE = 0
Const $MAXIMUM_CONNECTIONS = 25
$strComputer = "atl-ws-01"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$objNewShare = $objWMIService.Get("Win32_Share")
$errReturn = $objNewShare.Create(@ScriptDir & "\WebKiosk", "WebKiosk", 0, 25, "Exod-Kiosk Codes/Times")

Thanks

Link to comment
Share on other sites

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
if @error then 
  Msgbox (0,"ERROR","Error: Probably Can't create object")
  exit
endif

Just a thought.

Link to comment
Share on other sites

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
if @error then 
  Msgbox (0,"ERROR","Error: Probably Can't create object")
  exit
endif

Just a thought.

Ok.... Thanks. How can I fix it?

The thread I used was this one.

Link to comment
Share on other sites

@all

this will create a network share.

$strComputer = "."
$strPath = "c:\AutoIT"
$strName = "Scripts"
$intType = 0 ; share a disk drive resource
$intMaxAllowed = 10 
$strDescr = "AU Scripts"

$objWMI = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
 $objShare = $objWMI.Get("Win32_Share")
$intRC = $objShare.Create($strPath, $strName, $intType, $intMaxAllowed, $strDescr)

if $intRC <> 0 then
 ConsoleWrite ("Error creating share: " & $intRC)
else
 ConsoleWrite ("Successfully created share")
EndIf

Enjoy !!

ptrex

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...