VB script to download shares

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 16 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
radha434
Posts: 14
Last visit: Wed May 27, 2009 2:34 pm

VB script to download shares

Post by radha434 »

Hi I use the below vbscript to download shares from remote machine but
it gives the error as C:shares.vbs(7, 1) (null): 0x80041003 can
anybody help me.

' ------ SCRIPT CONFIGURATION ------
strComputer = "."
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:" & strComputer & "rootcimv2")
set colShares = objWMI.InstancesOf("Win32_Share")
for each objShare in colShares
WScript.Echo objShare.Name
WScript.Echo " Path: " & objShare.Path
WScript.Echo " Allow Max: " & objShare.AllowMaximum
WScript.Echo " Caption: " & objShare.Caption
WScript.Echo " Max Allowed: " & objShare.MaximumAllowed
WScript.Echo " Type: " & objShare.Type
WScript.Echo
next
User avatar
radha434
Posts: 14
Last visit: Wed May 27, 2009 2:34 pm

VB script to download shares

Post by radha434 »

Hi I use the below vbscript to download shares from remote machine but
it gives the error as C:shares.vbs(7, 1) (null): 0x80041003 can
anybody help me.

' ------ SCRIPT CONFIGURATION ------
strComputer = "."
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:" & strComputer & "rootcimv2")
set colShares = objWMI.InstancesOf("Win32_Share")
for each objShare in colShares
WScript.Echo objShare.Name
WScript.Echo " Path: " & objShare.Path
WScript.Echo " Allow Max: " & objShare.AllowMaximum
WScript.Echo " Caption: " & objShare.Caption
WScript.Echo " Max Allowed: " & objShare.MaximumAllowed
WScript.Echo " Type: " & objShare.Type
WScript.Echo
next
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

VB script to download shares

Post by jhicks »

So when you change the value of strComputer to a remote machine you get the error? Does it work for the localhost? It works fine for me both ways. What OS is on the remote computer? Are you running it with admin credentials for the remote computer? What happens when you use WBEMTest and run a query like "Select * from win32_Share" ?It looks like you're failing to make a WMI connection and return any data.
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

VB script to download shares

Post by jhicks »

So when you use Wbemtest to connect to the remote machine, can you successfully run the query with your current credentials, or do you need to specify admincredentials? If the latter, then you need to rewrite your script using the SWbemscripting object which allows you to specify alternate credentials.
User avatar
radha434
Posts: 14
Last visit: Wed May 27, 2009 2:34 pm

VB script to download shares

Post by radha434 »

Hi, yes you are right I am able to connect to remote machine using
Wbemtest by specifying alternate admincredentials. Pls help me how to
rewrite my scriot to specify alternate credentials
This topic is 16 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked