Program Detach;

{ Example for the NwConn unit / NwTP 0.6, (c) 1993,1995 R.Spronk     }

{ Detach from the fileserver whose name is in parameter #1,
  delete all drivemappings to directories of target server's volumes }

Uses nwMisc,nwConn,nwFile;

Var ConnId:Byte;
    Srvr:String;
begin
If paramCount<>1
 then begin
      writeln('ERR: Supply name of server to detach from as a parameter.');
      writeln;
      writeln('Detaches from server/ removes all drive mappings to server.');
      writeln('Returns errorlevel 1 when detaching was successful. 0 otherwise.');
      halt(0);
      end;
Srvr:=ParamStr(1);UpString(Srvr);
IF NOT GetConnectionId(Srvr,connId)
 then begin
      writeln('ERR: Not attached to server ',Srvr);
      halt(0);
      end;
DeleteConnectionsDriveMappings(connId);
IF DetachFromFileServer(connId)
 then halt(1)
 else halt(0);
end.
