Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in a Journal with Process.Start command

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012
Hi

In this journal I get a blank output:
Dim outfile As String = _
"C:\haviv\_00_vita_vme_std\_m3u_assy_002" & "\ugiiOutput.txt"

? can someone help to explain this.

Code:
 'Start an invisible process.

 'You can start a process and get its output without a visible window.
 'This shows how to changes to the System folder,
 'run the DOS Dir "*.exe" command and send the output to the Output.txt file.
 'The Windows XP command shell interpreter recognizes "&&" as a command separator,
 'thus, you can put multiple commands on a single line.

 ' "&&" command separator,
 ' ">>" redirects output into a file, append to existing 
 ' ">"  redirects output into a file, clear the existing. 
 ' Chr(34) = "

Option Strict Off

Imports System
Imports System.Diagnostics
Imports System.Security
Imports System.Windows.Forms

Module NXJournal

 Sub Main (ByVal args() As String)
 
    Dim myProcess As Process = New Process()
    Dim s As String

    Dim outfile As String = _
      "C:\haviv\_00_vita_vme_std\_m3u_assy_002" & "\ugiiOutput.txt" 
    '
    ' Get the System path. 
    '
    'Dim sysFolder As String = 
       'System.Environment.GetFolderPath(Environment.SpecialFolder.System)
    '
    Dim ugiiFolder As String = "C:\Program Files\Siemens\NX 8.5\UGII"

    MsgBox(" Changed to folder = " & ugiiFolder) 
    '
    ' Createe the command line. 
    '
    myProcess.StartInfo.FileName = "cmd.exe" 
    myProcess.StartInfo.Arguments = "/C cd " & ugiiFolder & _
        " && ug_clone -pim=Yes -o=clone:Import -Part=C:\_m3u_002\comp1.prt" & _
                                            " > " & Chr(34) & outfile & Chr(34) & " && exit"
    '
    ' Start the process in a hidden window.
    ' 
    myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal  'Hidden 
    myProcess.StartInfo.CreateNoWindow = False  'True 
    myProcess.Start()
    '
    ' Kill the process if it doesn't finish in one minute.
    ' 
    myProcess.WaitForExit() 
    'myProcess.WaitForExit(1000) 
    'If Not myProcess.HasExited Then 
        'myProcess.Kill() 
    'End If
    '
    ' Show the results.
    '
    MessageBox.Show("The 'ug_clone ' command window was " & _
        "closed at: " & myProcess.ExitTime & "." & System.Environment.NewLine & _
        "Exit Code: " & myProcess.ExitCode) 
    
    myProcess.Close()

 End Sub
End Module

Thank you in advanced
 
Replies continue below

Recommended for you

Cowski thank you.

My intention is to write a journal that run in native mode.
and manipulate an Assembly as the following:
Save original components parts names in part attribute.
change parts names to comply nxmanager mode, shorten long names
Replace spaces and like so.
and then run ug_clone.exe to import the assembly to nxmanager.

Thank you again.
 
In that case, definitely run "ugmanager_clone.bat" instead of ug_clone.
I ran your code on a test file and got an error of "need to have TCROOT/IMANROOT defined..." (yes we have TC installed). The "ugmanager_clone.bat" will set those environment variables before handing control over to ug_clone. Alternatively, you can set these variables yourself, before calling ug_clone.

www.nxjournaling.com
 
Ahh OK thank you very much.

meanwhile I opened a command prompte window changed directory
To ugii and run this
ug_clone -help > out.txt and this indeed
created a blank out.txt file. ? ?

I'll try it with ugmanager_clone.bat

Thank you again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor