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
.
..
...
#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
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 85 guests