Function AddToMyNetworkPlaces($Name,$Location,Optional $Comment)
Dim $Nethood,$Shell,$S,$D,$T
$AddToMyNetworkPlaces=1
If Exist($Location)
$Nethood=ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','NetHood')
If GetFileAttr($Nethood+'\'+$Name) & 16
; 'Link exists already. Exit the function.
Exit 80
EndIf
MD $Nethood+'\'+$Name
$D=$Nethood+'\'+$Name+'\'+'Desktop.ini'
$T=$Nethood+'\'+$Name+'\'+'target.lnk'
$S = SetFileAttr($Nethood+'\'+$Name,1)
$S = WriteProfileString ($D,'.ShellClassInfo','CLSID2','{0AFACED1-E828-11D1-9187-B532F1E9575D}')
$S = WriteProfileString ($D,'.ShellClassInfo','FLAGS','2')
$S = SetFileAttr($D,6)
$Shell = CreateObject('wscript.shell')
If @ERROR Exit @ERROR EndIf
$S = $Shell.CreateShortcut($T)
$S.TargetPath = $Location
$S.WorkingDirectory = $Location
If $Comment
$S.Description = $Comment
EndIf
$S.Save
If @ERROR Exit @ERROR Else $AddToMyNetworkPlaces=0 EndIf
Else
Exit 3
EndIf
EndFunction