Not so long ago I did write a VB script to create a small user interface.
The script waits for the end of execution of the DSMADMC command.
The problem I did not solve is the reception of the Return codes. The solution I
 found is that the script reads
the outputfile of the DSMADMC command to see if everything has been executed as
it should. For me this is not professional enough
but it works.

The script is something like this: (only an extraction of the function and the
main subroutine)

Public Function WaitCMD(ByVal JobToDo As String, Optional qResult) As Long

   .....

   On Error Resume Next
      ProcessID = Shell(JobToDo, vbNormalFocus)
      If Err Then
         WaitCMD = vbObjectError + Err.Number
         Debug.Print "Shell Exec Error"; WaitCMD
      Exit Function
      End If
   On Error GoTo 0

   hProcess = OpenProcess(fdwAccess, False, ProcessID)
   nRet = WaitForSingleObject(hProcess, INFINITE)
   Call CloseHandle(hProcess)

   Select Case nRet
      Case WAIT_TIMEOUT: Debug.Print "Timed out!"
      Case WAIT_OBJECT_0: Debug.Print "Normal completion."
      Case WAIT_ABANDONED: Debug.Print "Wait Abandoned!"
      Case WAIT_FAILED: Debug.Print "Wait Error:"; Err.LastDllError
   End Select
   ......
End Function

Sub Main()
.....
   TsmCmd = "select domain_name from domains"
   Ret = WaitCMD("dsmadmc.exe -id=" + UseNam + " -pa=" + Pwd + " -outfile=" +
OuFil + " " + TsmCmd)
.....
End Sub

Hope this helps

Michel





"Fletcher, Leland D." <[EMAIL PROTECTED]> on 02/06/2001 05:43:35 PM

Please respond to "ADSM: Dist Stor Manager" <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Michel Engels/BE/Devoteam)

Subject:  DSMADMC from Visual Basic Shell Function?



I'm attempting to write a VB application to monitor the daily ADSM schedule
and to issue several commands throughout the day. My problem is that when I
use the shell command nothing seems to be working. I do not get any errors
but I do not get any output either. The format of the shell command I'm
using is provided below. I have not set any environment variables and plan
on executing the VB application under Windows 2000.

The following should issue the "q fi".

Private Sub Command1_Click()
    x = Shell("C:\Progra~1\IBM\ADSM\saclient\DSMADMC.EXE -id=admin -pa=x
-outfile=c:\cmdout.txt q fi")
End Sub

The function runs without error but I do not get the -outfile allocated.
Thanks in advance for any input to my problem!

Lee Fletcher
Network Project Integrator
AmerenUE Callaway Plant
[EMAIL PROTECTED]

Reply via email to