if IsWscript then if wscript.arguments.count <> 1 then sServer=Inputbox("Computer name?") if len(sServer)=0 then usage else if instr(wscript.arguments(0),"-") > 0 then usage if instr(wscript.arguments(0),"/") > 0 then usage sServer=replace(wscript.arguments(0),"\","") end if else if wscript.arguments.count <> 1 then usage if instr(wscript.arguments(0),"-") > 0 then usage if instr(wscript.arguments(0),"/") > 0 then usage sServer=replace(wscript.arguments(0),"\","") end if set oWBEM=WMIConnect(sServer) sResult="Shares on "&sServer&":"&vbcrlf&vbcrlf set oShares=oWBEM.ExecQuery("select * from Win32_Share") sResult=sResult&"Name,Description,Local Path" for each oShare in oShares sResult=sResult&oShare.Name&","&oShare.description&","&oShare.path&vbcrlf next wscript.echo sResult Function IsWscript IsWscript=False if instr(lcase(wscript.fullname),"wscript.exe")>0 then IsWscript=True End Function Function WMIConnect(sServer) 'On Error Resume next Set oLocator=CreateObject("WbemScripting.SWbemLocator") Set oWMISvc=oLocator.ConnectServer(sServer,"root/cimV2") If Err.Number <> 0 Then WScript.Echo("error") sErr="0x"&Cstr(hex(Err.Number)) sDesc=Err.Description Err.Clear() Set oWMISvc=oLocator.ConnectServer(sServer,"root/cimV2",,,,ntlmdomain) If Err.Number <> 0 Then WScript.Echo "Error "&sErr&" ("&sDesc&") connecting to WMI on server "&sServer Set WMIConnect=WScript.Name Exit Function End If End If Set WMIConnect=oWMISvc End Function Sub Usage sUsage="Usage:"&vbcrlf&vbcrlf&"cscript //nologo listshares.vbs [servername]"&vbcrlf wscript.echo sUsage wscript.quit End Sub