Topic
  • 1 reply
  • Latest Post - ‏2012-08-12T20:40:48Z by Dunnel
PN9X_JESUS_GONZALEZ
PN9X_JESUS_GONZALEZ
1 Post

Pinned topic TSM & VB.NET

‏2012-05-12T18:44:47Z |
People, could someone help me with some example code to query from VB.NET to TSM?
thanks
Updated on 2012-08-12T20:40:48Z at 2012-08-12T20:40:48Z by Dunnel
  • Dunnel
    Dunnel
    1 Post

    Re: TSM & VB.NET

    ‏2012-08-12T20:40:48Z  
    > PN9X_JESUS_GONZALEZ wrote:
    > People, could someone help me with some example code to query from VB.NET to TSM?
    >
    >
    > thanks
    Hi Jesus, I use the 'dsmadmc.exe' in batch mode.
    Like this...
    Directory.SetCurrentDirectory("C:\Program Files\Tivoli\tsm\baclient\")
    Dim bResult As Boolean = False
    Dim sResult AS String = ""
    bResult = x_BatchAndWait("C:\Program Files\Tivoli\tsm\baclient\dsmadmc.exe", _
    "-id=username -passw=password -tcps=9.9.9.9 -dataonly=yes q pr", _
    sResult)

    Private Function x_BatchAndWait(ByVal ProcessPath As String, Optional ByVal ProcessParms As String = "", Optional ByRef ProcessOutput As String = "") As Boolean
    Dim objProcess As System.Diagnostics.Process
    Try
    objProcess = New System.Diagnostics.Process()
    objProcess.StartInfo.FileName = ProcessPath
    If ProcessParms "" Then
    objProcess.StartInfo.Arguments = ProcessParms
    End If
    objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
    objProcess.StartInfo.CreateNoWindow = True

    objProcess.StartInfo.UseShellExecute = False
    objProcess.StartInfo.RedirectStandardOutput = True
    objProcess.StartInfo.RedirectStandardInput = True
    objProcess.StartInfo.RedirectStandardError = True
    objProcess.Start()
    'Wait until the process passes back an exit code
    objProcess.WaitForExit(5000)
    swTraceWriter_Write("objProcess.WaitForExit(5000)")
    Do Until objProcess.HasExited
    Application.DoEvents()
    System.Threading.Thread.Sleep(250)
    swTraceWriter_Write("System.Threading.Thread.Sleep(250)")
    Loop
    'Free resources associated with this process
    If objProcess.HasExited Then
    ProcessOutput = objProcess.StandardOutput.ReadToEnd
    Return True
    Else
    ProcessOutput = objProcess.StandardOutput.ReadToEnd
    objProcess.Kill()
    Return False
    End If
    objProcess.Close()
    Catch ex As Exception
    ProcessOutput = "WIN32EXC " & ex.Message
    Return False ' "The specified executable is not a valid Win32 application.","The system cannot find the path specified","Thesystem cannot find the file specified"
    End Try
    End Function

    Hope that this is some help.