Article

AutoIT map network drive

I had a small project that involved looking-up an IP address of a host, then use that IP address to map a network share. Below is what I came up with. Note: the variable '$me' was declared earlier on in the script.

 
; Read host list
$input = FileOpen("C:\host-list.csv", 0)
 
While 1
	$line = FileReadLine($input)
	If @error = -1 Then ExitLoop
	If StringInStr($line, $me) Then
		$split = StringTrimRight($line, 2)
		$drivemap = "X:"
		DriveMapAdd($drivemap, '\\' & $split & '\SHARE')
 
		$oShell = ObjCreate("shell.application")
		$oShell.NameSpace($drivemap).Self.Name = ( "FRIENDLY NAME" & $me )
 
	EndIf
WEnd
 

No comments yet.

Leave a Reply