net use R: /DELETE
net use R: \\srv-win-inf-201\l_um_npr
It does not seems to work, and I don't receive any error messages.
Thanks for any suggestions how to make the script work.
Regards
Frank Krogh
______________________________
Option Explicit
Private Const SYNCRONIZE=&H100000, INFINITE=-1&
'Declare Win32 API functions
Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal
dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal
dwProcessId As Long) As Long
Declare Function WaitForSingleObject Lib "kernel32" Alias
"WaitForSingleObject" (ByVal hHandle As Long, ByVal dwMilliseconds As
Long) As Long
Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal
hObject As Long) As Long
Sub WaitExecution(ByVal ProgramName As String)
'Run the application specified by ProgramName and wait until the end
of its
'execution.
Dim PID As Long, hProcess As Long
On Error GoTo ShellErr
PID=Shell(ProgramName,vbNormalFocus)
On Error GoTo 0
hProcess=OpenProcess(SYNCRONIZE,0,PID)
If hProcess<>0 Then
WaitForSingleObject hProcess, INFINITE
CloseHandle hProcess
End If
Exit Sub
ShellErr:
MsgBox "Error starting task "+ProgramName + vbCrLf + Err.Description
Exit All
End Sub
Sub DOS(ByVal Path As String, ByVal DOSCommand As String)
'Launch the DOS command specified by the parameter DOSCommand and wait
until its execution
'ends.
'Path parameter specifies the path to set before running the
DOSCommand, If Path="", then
'the active path will be used.
' If Trim(Path)<>"" Then
' ChDir Path
' End If
WaitExecution "COMMAND.COM /c "+DOSCommand
End Sub
Sub Main()
Dim Cmd As String
Cmd="net use R: /DELETE"
DOS "",Cmd
Cmd="net use R: \\srv-win-inf-201\l_um_npr"
DOS "",Cmd
' If Cmd<>"" Then
' DOS "",Cmd
' End If
End Sub
If you are in distributed mode, the command will be executed on the
front-end machine, but that would not affect the backend file system.
Also, if the file system of the R drive is in use or is your current
drive, the net use /delete will fail. It isn't pbvious from this
script what happens to any output the command might produce.
Also, this script is going to a lot of trouble to make the commands
operate synchronously. Since vesion 16 scripts automatically run
synchronously, so that code is unnecessary.
But why not just use the HOST command? It will execute one or more
DOS commands synchronously. Any output produced appears automatically
in the Viewer.
HTH,
Jon Peck