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
info@marcoboschi.it
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
...
..
.
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
.
..
...I Log to server with this fivewin app from c:\myfolder
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
#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 lAlreadyConnectedThanks,
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
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)
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
endifOk
Thank you Anser
Thank you Otto
It works
MarcoBoschi,
Exist in xHarbour this:
NetRedir( <cLocal> , ;
<cServer> , ;
[<cPassword>], ;
[<lShowError>] ) --> lSuccess
Regards
? 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
Thanks to all
marco