Network only works after selecting drive

Network only works after selecting drive

Postby Marc Vanzegbroeck » Tue Dec 20, 2011 6:52 am

Hi,

On a network of a client I want to copy files from one PC to an other.
I check if the path exist with
Code: Select all  Expand view
IF file(vNetwerkPath+'\VLD.EXE')


It work very nice, but...
If the client first start the PC, he have to go to the explorer and select the drive before it works. Otherwise is returns False, and I can't copy the files.
The network map is configured that it automatic reconnect after startup.
Does anyone know a solution for this problem?
PS The problem is not only with my program, also other programs need first selecting the drive before it works.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network only works after selecting drive

Postby driessen » Tue Dec 20, 2011 8:41 am

Mark,

This is a very well know Windows-problem.

I have been looking for a solution for many, many years. But unfortunately, I never found one.

What do I tell to my customers ?
I always create a shortcut on the desktop for the mapped drive. And I always tell my customer to doubleclick on this shortcut before doing anything else. If so, he/she is sure that the networkmapping is working fine.

I'm afraid that is the only solution, to my opnion.

Good luck.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Network only works after selecting drive

Postby Marc Vanzegbroeck » Tue Dec 20, 2011 10:26 am

Michel,

I already told my customer to do this, but she find it to difficult to remember :roll: and she ask me to try to fix it so she doesn't have to select the drive each time after starting the PC :(

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network only works after selecting drive

Postby StefanHaupt » Wed Dec 21, 2011 7:55 am

Marc,

maybe you can use this code snippet to check the connection

Code: Select all  Expand view
//--------------------------------------------------------------------------
FUNCTION MapNetworkDrive(cShare, cDevice)
RETURN(WNetAddConnection(cShare,cDevice))

//--------------------------------------------------------------------------

FUNCTION DelNetworkDrive(cDevice)
RETURN(WNetCancelConnection(cDevice,.T.))

//--------------------------------------------------------------------------
#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbapiitm.h"

#define MAX_FILE_NAME 1024

HB_FUNC( WNETADDCONNECTION )
{
 char cLocal[MAX_FILE_NAME];
 BOOL Result = FALSE ;
 int nLength ;
    if (ISCHAR(1) && (hb_parclen(1) >5) && ISCHAR(2) )
    {
  nLength= hb_parclen(2) ;
  if ((nLength>=2) && (nLength< MAX_PATH-1) )
  {
   memcpy(cLocal, hb_parc(2), 2) ;
   cLocal[2]= '\0';
   Result = ( WNetAddConnection(hb_parc(1),NULL,cLocal) == NO_ERROR) ;
  }
 }
 hb_retl(Result) ;
}

HB_FUNC( WNETCANCELCONNECTION )
{
 char cLocal[3];
 BOOL Result = FALSE ;
 if (ISCHAR(1) && (hb_parclen(1) >= 2))
 {
  memcpy(cLocal, hb_parc(1), 2) ;
  cLocal[2]= '\0';
  Result = (WNetCancelConnection(cLocal,ISLOG(2) && hb_parl(2)? TRUE :
FALSE)== NO_ERROR) ;
 }
 hb_retl(Result) ;
}

#pragma ENDDUMP

/*
nRetCode := WNetAddConnection2(  RemoteName, Password, UserName, LocalName )

   if nRetCode <> 0

      if nRetCode = 85
         // alreday connected

      elseif nRetCode = 67
         msginfo( "RemoteName " + RemoteName + CRLF +;
            "Password  " + Password  + CRLF +;
            "UserName  " + UserName  + CRLF +;
            "LocalName " + LocalName + CRLF +;
            CRLF +;
            "System error 67 - The network name cannot be found" )

      elseif nRetCode = 1219
         msginfo( "RemoteName " + RemoteName + CRLF +;
            "Password " + Password + CRLF +;
            "UserName " + UserName + CRLF +;
            "LocalName " + LocalName + CRLF +;
            CRLF +;
            "System error 1219 - Multiple connections to a server" )
      endif

   endif
*/
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Network only works after selecting drive

Postby Marc Vanzegbroeck » Wed Dec 21, 2011 9:49 am

Stefan,

Thanks for the code. I will try it and let you know the result.

Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network only works after selecting drive

Postby Marco Turco » Wed Dec 21, 2011 2:19 pm

Hi,
this problem generally is due to the fact that the user on the windows client is not defined on the server.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Network only works after selecting drive

Postby Marc Vanzegbroeck » Thu Dec 22, 2011 6:01 pm

Stefan,

Your code seems to work. Now they can access the files without selecting the drive!

Thanks,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network only works after selecting drive

Postby StefanHaupt » Fri Dec 23, 2011 8:16 am

:D
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Network only works after selecting drive

Postby avista » Mon Dec 26, 2011 9:23 am

Hi ,
I use this:

LOCAL cKomanda := ""

cKomanda := "command.com /c "+"NET USE "+sDisk+": "+"\\"+ALLTRIM(sPat)+"\"+ALLTRIM(sName)+" /yes"
WinExec(cKomanda,0)

// Your code here

cKomanda := "command.com /c "+"NET USE "+sDisk+": "+"/DELETE /YES"
WinExec(cKomanda,0)


Regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 92 guests