net use n: \\myserver\apps

net use n: \\myserver\apps

Postby MarcoBoschi » Thu Jul 01, 2010 1:25 pm

Hi,
this batch file works fine:

net use n: \\dbserver\apps /user:marco mypassword
n:
cd\testprog
test.exe
c:
net use n: /delete

Is it possible to use fivewin/xHarbour program?

Thanks
marco
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: net use n: \\myserver\apps

Postby Willi Quintana » Thu Jul 01, 2010 2:28 pm

Use this mode.
If after running test.exe remove the unit n, test.exe may collapse, test.exe should generate a return variable or a file flag, to establish whether test.exe terminates, then remove the unit n.
is to be tested
Code: Select all  Expand view

...
..
.
cRVar := " \\dbserver\apps /user:marco mypassword"

 cOrden := "net use " + cRVar
 cOrden := "COMMAND.COM /C " + cOrden
 WaitRun(cOrden, 0)   // ejecutor externo

WinExec("test.exe")
If file("n:oktest.flg")
   cOrden := "net use n: /delete"
   cOrden := "COMMAND.COM /C " + cOrden
   WaitRun(cOrden, 0)   // ejecutor externo
EndIf
.
..
...
 
Last edited by Willi Quintana on Thu Jul 01, 2010 2:39 pm, edited 2 times in total.
User avatar
Willi Quintana
 
Posts: 1002
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: net use n: \\myserver\apps (solved)

Postby MarcoBoschi » Thu Jul 01, 2010 2:29 pm

I Log to server with this fivewin app from c:\myfolder

#include "fivewin.ch"

FUNCTION MAIN( )

Waitrun( "net use n: \\dbserver\apps /user:marco mypassword" , 0 )

lChdir( "n:\testprog" )

Winexec( "test.exe" , 1)

RETURN NIL

At the end of test.prg

lChdir( "c:\myfolder" )
WinExec( "net use n: /delete" , 0 )

RETURN NIL

thanks you all for your attention

Marco
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: net use n: \\myserver\apps

Postby anserkk » Fri Jul 02, 2010 7:31 am

Another way to do the following tasks. :)

1. Map a network drive
2. Remove a mapped network drive
3. Check whether a drive letter is already mapped or not.

Code: Select all  Expand view
#include "Fivewin.ch"

//--------------------------//
Function Main()
    Local oDlg,oBtn1,oBtn2,oBtn3
    Local cDriveLetter:="M:", cRemotePath:="\\Server\ShareName"
   
    DEFINE DIALOG oDlg FROM 5,5 to 25,65 TITLE "Network Drive mapping"
   
    @3,2 BUTTON oBtn1 PROMPT "Map a Network Drive" SIZE 60,20;
         ACTION (MapDrive( cDriveLetter, cRemotePath))
         
    @3,15 BUTTON oBtn2 PROMPT "Remove Mapped Drive" SIZE 60,20;
         ACTION RemoveMapDrive( cDriveLetter)
         
    @3,28 BUTTON oBtn2 PROMPT "Is Drive Mapped ?" SIZE 60,20;
         ACTION MsgInfo(if(IsDriveMapped( cDriveLetter),"Mapped to "+ cDriveLetter,"Not mapped"))        
         
   
    ACTIVATE DIALOG oDlg

Return NIL

//-----------------------------------------------------------------------//
Function MapDrive(cDriveLetter,cRemotePath,lPermanent,cUserName,cPassword)
    Local oNetwork,oError
    DEFAULT lPermanent:=.F.
    oNetwork:=CreateObject("WScript.Network")
    TRY
        oNetwork:MapNetworkDrive(cDriveLetter, cRemotePath,lPermanent,cUserName,cPassword)
    CATCH
        MsgInfo("Unable to map "+cDriveLetter+ " to "+cRemotePath)
    END
Return NIL

//-----------------------------------------------------------------------//
Function RemoveMapDrive(cDriveLetter)
    Local oNetwork
    oNetwork:=CreateObject("WScript.Network")
    TRY
        oNetwork:RemoveNetworkDrive(cDriveLetter)
    CATCH
        MsgInfo("Unable to remove "+cDriveLetter)
    END
Return NIL

//-----------------------------------------------------------------------//
Function IsDriveMapped(cDriveLetter)
    Local oNetwork,oNetworkDrives,i,lAlreadyConnected:=.F.
    oNetwork:=CreateObject("WScript.Network")
    oNetworkDrives:=oNetwork:EnumNetworkDrives()

    For i:=0 to oNetworkDrives:Count - 1 STEP 2
        if Upper(oNetworkDrives:Item(i)) == Upper(cDriveLetter)
            lAlreadyConnected:=.T.
        Endif
    Next
Return lAlreadyConnected


Regards
Anser
User avatar
anserkk
 
Posts: 1329
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: net use n: \\myserver\apps

Postby MarcoBoschi » Mon Jul 05, 2010 8:40 am

Thanks,
but I have this error
Application
===========
Path and name: c:\za2\connec.exe (32 bits)
Size: 1,903,616 bytes
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 07/05/10, 10:39:53
Error description: Error WScript.Network/3 DISP_E_MEMBERNOTFOUND: MAPNETWORKDRIVE
Args:
[ 1] = C n:
[ 2] = C \\dbserver\apps
[ 3] = L .F.
[ 4] = U
[ 5] = U

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:MAPNETWORKDRIVE(0)
Called from: connec.prg => MAPDRIVE(28)
Called from: connec.prg => (b)MAIN(11)
Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK(176)
Called from: control.prg => TBUTTON:HANDLEEVENT(1427)
Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
Called from: => SENDMESSAGE(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND(407)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT(928)
Called from: => DIALOGBOXINDIRECT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
Called from: connec.prg => MAIN(20)
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: net use n: \\myserver\apps

Postby Otto » Mon Jul 05, 2010 9:20 am

Hello Marco,
I use this code to connect to network:

Code: Select all  Expand view
  LOCAL RemoteName   := GetPvProfString( "SETUPDATEN", "ServerName",    "\\DEMO\lwc", ".\INI\TOUCH.INI" )
   LOCAL UserName     := GetPvProfString( "SETUPDATEN", "User",          "test",       ".\INI\TOUCH.INI" )
   LOCAL Password     := GetPvProfString( "SETUPDATEN", "ServerPasswort","whdemo",     ".\INI\TOUCH.INI" )
   LOCAL LocalName    := GetPvProfString( "SETUPDATEN", "ServerLW",      "S:",         ".\INI\TOUCH.INI" )

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

   if nRetCode <> 0

      if nRetCode = 85
         //bereits verbunden

      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
 


Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6004
Joined: Fri Oct 07, 2005 7:07 pm

Re: net use n: \\myserver\apps

Postby MarcoBoschi » Mon Jul 05, 2010 9:47 am

Ok
Thank you Anser
Thank you Otto
It works
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: net use n: \\myserver\apps

Postby wmormar » Mon Jul 05, 2010 4:48 pm

MarcoBoschi,

Exist in xHarbour this:

NetRedir( <cLocal> , ;
<cServer> , ;
[<cPassword>], ;
[<lShowError>] ) --> lSuccess

Regards
William, Morales
Saludos

méxico.sureste
User avatar
wmormar
 
Posts: 1073
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Re: net use n: \\myserver\apps

Postby derpipu » Wed Jul 07, 2010 3:29 pm

? cDrvMapToLetter( "\\desarrollo_pc\utilerias" ) // Nos muestra la Letra de la unidad de red
? cLetterToDrvMap( "Z:" ) // Nos muestra la unidad de Red de la letra
? NETREDIR( "LPT1", "\\desarrollo_pc\LX-300") // Mapeamos una unidad de red a una Letra, puede ser datos o impresoras
? NETRMTNAME( "LPT1" ) // Nos regresa la unidad de red completa en base al puerto o unidad elegido
? NETCANCEL( "LPT1" ) // eliminar puertos de red
Luis Fernando Rubio Rubio
derpipu
 
Posts: 94
Joined: Tue Mar 28, 2006 4:09 pm
Location: Tequila, Jalisco Mexico

Re: net use n: \\myserver\apps

Postby MarcoBoschi » Thu Jul 08, 2010 6:54 am

Thanks to all

marco
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 72 guests