home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / setdrv.exe / SETDRIVE.C next >
C/C++ Source or Header  |  1994-09-29  |  2KB  |  87 lines

  1.  
  2. /****************************************************************************
  3. **        DISCLAIMER
  4. **
  5. **    Novell, Inc. makes no representations or warranties with respect to
  6. **    any NetWare software, and specifically disclaims any express or
  7. **    implied warranties of merchantability, title, or fitness for a
  8. **    particular purpose.
  9. **
  10. **    Distribution of any NetWare software is forbidden without the
  11. **    express written consent of Novell, Inc.  Further, Novell reserves
  12. **    the right to discontinue distribution of any NetWare software.
  13. **
  14. **    Novell is not responsible for lost profits or revenue, loss of use
  15. **    of the software, loss of data, costs of re-creating lost data, the
  16. **    cost of any substitute equipment or program, or claims by any party
  17. **    other than you.  Novell strongly recommends a backup be made before
  18. **    any software is installed.   Technical support for this software
  19. **    may be provided at the discretion of Novell.
  20. ****************************************************************************
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <nwcalls.h>
  25. #include <nwnet.h>
  26.  
  27. void main (int argc, char *argv[])
  28. {
  29.     NWCONN_HANDLE     newConn;
  30.     NWCCODE        ccode;
  31.     int            i;
  32.     char         userName[100], password[100];
  33.  
  34.     if (argc != 4)
  35.     {
  36.         printf ("\nUsage:  SETDRIVE drivenumber server directory\n");
  37.         printf ("drivenumber A=1, B=2, etc...\n");
  38.         printf ("server name of server directory exists on\n");
  39.         printf ("directory path of directory\n");
  40.         return;
  41.     }
  42.  
  43.     strupr (argv[2]);
  44.     strupr (argv[3]);
  45.  
  46.     ccode = NWCallsInit (NULL,NULL);
  47.     if (ccode) return;
  48.  
  49.     ccode = NWAttachToFileServer (argv[2], 0, &newConn);
  50.     if ((ccode != 0) && (ccode != 0x8800))
  51.     {
  52.         printf ("\nNWAttachToFileServer returned error %04X\n",
  53.             ccode);
  54.         return;
  55.     }
  56.  
  57.     if (ccode == 0x8800)
  58.     {
  59.         ccode = NWGetConnectionIDFromName (strlen (argv[2]), argv[2], &newConn);
  60.     }
  61.     else
  62.     {
  63.         printf ("\nLogging into %s\nUser Name:  ", argv[2]);
  64.         gets (userName);
  65.         printf ("Password:  ");
  66.         gets (password);
  67.  
  68.         strupr (userName);
  69.         strupr (password);
  70.  
  71.         ccode = NWLoginToFileServer (newConn, userName, OT_USER, password);
  72.         if (ccode)
  73.         {
  74.             printf ("\nNWLoginToFileServer returned error %04X\n",
  75.                 ccode);
  76.             return;
  77.         }
  78.     }
  79.  
  80.     ccode = NWSetDriveBase (atoi (argv[1]), newConn, 0, argv[3], 0);
  81.     if (ccode)
  82.     {
  83.         printf ("\nNWSetDriveBase returned error %04X\n",
  84.             ccode);
  85.         return;
  86.     }
  87. }