WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

wNT
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

wntGetCon Error 509 Network Component is Not Started or Invalid

 Keywords: wntGetCon Error 509 Network Component is Not Started or Invalid 

Question:

I am getting the error 509 Network Component is Not Started or Invalid when running this code on a Win7 System.
drives = "HIJKLMNOPQRSTUVWXYZ"
cnt = StrLen(drives)
BoxText("Remove existing maps to APOLLO")
for i = 1 to cnt
   drv = StrSub(drives, i, 1)
   netsrc = StrUpper( wntGetCon(drv) )
   if StrIndex(netsrc, "\\APOLLO\", 1, @FWDSCAN) >= 1 then   ; contains APOLLO, delete the connection
      wntCancelCon(drv:":", @TRUE, @TRUE)
      BoxText("Deleting the map for %drive% as %netsrc%")
      timedelay(2)
   endif
next ; i

Answer:

You will get the error 509 'Network Component is Not Started or Invalid' is you pass wntGetCon a drive letter that is a virtual file system drive. DebugTrace can be used to determine which drive letter is causing the error.

User Reply:

DebugTrace indicates it is failing on the Q: drive. Upon closer inspection of the workstation the Q: drive is one that Microsoft Virtualization creates if you use their new HyperV.

Answer:

Rather than iteratively passing drive lettters to wntCancelCon, I recommend using DiskScan(4). This DiskScan request returns only a list of remote (network) drives.
drives = DiskScan( 4 )
cnt = ItemCount( drives, @TAB )
BoxText( "Remove existing maps" )
for i = 1 to cnt
   drv = ItemExtract( i, drives, @TAB )
   netsrc = StrUpper( wntGetCon( drv ) )
   if StrIndex( netsrc, "\\APOLLO\", 1, @FWDSCAN ) >= 1 then   ; contains APOLLO, delete the connection
      wntCancelCon( drv, @TRUE, @TRUE )
      BoxText( "Deleting the map for ":drive:" as ":netsrc )
      timedelay( 2 )
   endif
next 

Article ID:   W18003
Filename:   wntGetCon Error 509 Network component is Not Started or Invalid.txt
File Created: 2010:06:30:09:03:06
Last Updated: 2010:06:30:09:03:06