NXProf
Mechanical
- Nov 28, 2012
- 45
Hello,
I'm attempting to initiate a .bat file from NX with VB code, in which I've Googled searched and tried several bits of code, but without success. Can someone please help guide me on the right track? Later, I will embed this section of code into a larger program without shelling out to DOS.
The attempts I've made thus far are as follows:
Thank you greatly for your help ahead of time.
NX Prof
I'm attempting to initiate a .bat file from NX with VB code, in which I've Googled searched and tried several bits of code, but without success. Can someone please help guide me on the right track? Later, I will embed this section of code into a larger program without shelling out to DOS.
The attempts I've made thus far are as follows:
Code:
' NX 7.5.5.4
'
Option Strict Off
Imports System
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
Imports System.Windows.Forms.MessageBox
Imports NXOpen
Imports NXOpen.UF
'___________________________________________
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
'_____________________________________________________________________________
[b]'1st attempt:[/b]
'Dim shell As New wscript.shell
'shell.run("H:\plot_files\MULTI-TIFF-MAKER\MakeTif.bat")
'_____________________________________________________________________________
[b]'2nd attempt:[/b]
'System.Diagnostics.Process.Start("H:\plot_files\MULTI-TIFF-MAKER\MakeTif.bat")
'_____________________________________________________________________________
[b]'3rd attempt:[/b]
'Dim psi As New ProcessStartInfo("H:\plot_files\MULTI-TIFF-MAKER\MakeTif.bat")
'psi.RedirectStandardError = True
'psi.RedirectStandardOutput = True
'psi.CreateNoWindow = False
'psi.WindowStyle = ProcessWindowStyle.Hidden
'psi.UseShellExecute = False
'Dim process As Process = Process.Start(psi)
'Dim p As New System.Diagnostics.Process()
'p.StartInfo.FileName = "H:\plot_files\MULTI-TIFF-MAKER\MakeTif.bat"
'p.Start()
'_____________________________________________________________________________
[b]'4th attempt:[/b]
'Shell("H:\plot_files\MULTI-TIFF-MAKER\MakeTif.bat", AppWinStyle.Hide)
'_____________________________________________________________________________
[b]'5th attempt:[/b]
'Dim psi As New System.Diagnostics.ProcessStartInfo("H:\plot_files\MULTI-TIFF-MAKER\MakeTif.bat")
'psi.RedirectStandardOutput = True
''psi.WindowStyle = ProcessWindowStyle.Hidden
'psi.UseShellExecute = False
'Dim listFiles As System.Diagnostics.Process
'listFiles = System.Diagnostics.Process.Start(psi)
'Dim myOutput As System.IO.StreamReader = listFiles.StandardOutput
'listFiles.WaitForExit(2000)
''If listFiles.HasExited Then
'' Dim output As String = myOutput.ReadToEnd
'' Debug.WriteLine(output)
''End If
'_____________________________________________________________________________
[b]'6th attempt:[/b]
'Process.Start("H:\plot_files\MULTI-TIFF-MAKER\MakeTif.bat")
End Sub
End Module
Thank you greatly for your help ahead of time.
NX Prof