Journal or Macro to run .EXE files
Journal or Macro to run .EXE files
(OP)
We have an .EXE file that we would like to create a button to automatically run. When I recorded a Macro to run it, it only partially worked. We would hit the button and the macro would run like it is supposed to. But at one point when the exe file goes into a second part where the user is supposed to select something, the exe file stops working correctly. It will allow you to select what you need to select in its options but its as if its buttons stop controlling anything. .... HOWEVER ..... If we hit CTRL-U and run the EXE file without the macro. it works perfect.
I have come to the conclusion at this point that what happens is the exe file starts running and the macro is still recording until you are finished. So the macro is running and the exe is running and cancelling each other out some how. I think what we need is a macro or a journal that will allow us to run the exe file, but will stop running as soon as the exe file has started.
I tried to record a Journal but cannot find in the journal where it opens or runs the exe file. Instead it looks as if it records everything the exe file does instead.
Is there a simple macro or Journal that just runs an exe file, that I could just go into it and replace the path and file with the one I want it to run here?
I have come to the conclusion at this point that what happens is the exe file starts running and the macro is still recording until you are finished. So the macro is running and the exe is running and cancelling each other out some how. I think what we need is a macro or a journal that will allow us to run the exe file, but will stop running as soon as the exe file has started.
I tried to record a Journal but cannot find in the journal where it opens or runs the exe file. Instead it looks as if it records everything the exe file does instead.
Is there a simple macro or Journal that just runs an exe file, that I could just go into it and replace the path and file with the one I want it to run here?





RE: Journal or Macro to run .EXE files
BUTTON My_Button
LABEL Executing external program for...
ACTIONS "Start MyPath\MyExecutable.exe"
NX 9.0.3.4
NX 10 (Testing)
Windows 7 64 (Windows 8.1 Tablet)
RE: Journal or Macro to run .EXE files
RE: Journal or Macro to run .EXE files
CODE
Option Strict Off Imports System Imports NXOpen Module Module1 Sub Main() 'path to file Dim myfile As String = "c:\myfile.txt" Try System.Diagnostics.Process.Start(myfile) Catch ex As Exception Msgbox("Specified file: " & myfile & " Cannot be opened") End Try End Sub End ModuleWith best regards
Michael
RE: Journal or Macro to run .EXE files
I tried the code but it doesnt seem to be working. I tried it as it is below, and I tried replacing "myfile" with the file name in the other places as well. I tried it with the .exe and without it in the file name.
As it is below, I get a Framework error. An Unhandled Expression message. If I just go to File - Execute - NX Open, the .exe file works fine.
It may make a difference to know I am in NX9 and using Journal with Visual Basic, Unicode.
I know the company that issued this .exe file to us has a button that works for it at their place. My boss said he is going to see if they can just send us the info to make one that works here. But if you know where I am going wrong, I would still like to know for my own learning if nothing else. I need to find a book on Journal language. lol
------------------------------------------------
Option Strict Off
Imports System
Imports NXOpen
Module Module1
Sub Main()
'path to file
Dim myfile As String = "R:\NX9\Tooling\Hole Check GUI.exe"
Try
System.Diagnostics.Process.Start(myfile)
Catch ex As Exception
Msgbox("Specified file: " & myfile & " Cannot be opened")
End Try
End Sub
End Module
RE: Journal or Macro to run .EXE files
With best regards
Michael
RE: Journal or Macro to run .EXE files
and it thinks "Check" and "GUI.exe" are arguments.
Try placing triple quotes around the path name.
CODE
www.nxjournaling.com
RE: Journal or Macro to run .EXE files
I asked my boss about posting the file but he said no to that as well as the actual error due to privacy issues. He said the company that made it has a button that works for them, so he is just going to get them to set us up with the button to run the file.
Another strange thing that I came across is that NX gives us the option in Customization to make our own command and pick an image for it and such. I did this and it seems to work fine. When we did it on my leaders NX the same way, it didnt work for him. So there is a chance something weird is just happening with our installation or with licensing bundles. Either way, I am ordered to let it go now, so I will likely never know what it was for sure.
RE: Journal or Macro to run .EXE files
www.nxjournaling.com
RE: Journal or Macro to run .EXE files
1) Change name of file, for example remove spaces
2) Put this file on your local drive for example c:\
3) Try run journal with different .exe file for example some kind of installer or something.
4) Run this Journal on different NX (8.5?) or on different machine
If one of those methods will work, then We can find the answer. Please upload picture with error message.
With best regards
Michael
RE: Journal or Macro to run .EXE files
I am sorry but I cannot post a lot of info due to privacy requirements with another company and my boss saying "no". lol
I have tried the triple quotes. It made no difference.
If I use a Journal, it always gives me a "Microsoft .NET Framework" error. Saying.... Unhandled exception has occurred in your application. If you click Continue, the application eill ignore this error and attempt to continue. If you click Quit, the application will close immediately. ..... however, if I click continue, it goes to the next step in the .exe file where I need to pick from several choices on what to look at, but the window that comes up is empty. But if I run the .exe file manually, I will receiver several choices.
I tried using a macro for this. But when I execute the .exe file the macro is still recording. When it is played back, the .exe file will run correctly, but when it gets to the user options again, there is still a wheel rolling like it is thinking (which there shouldnt be) and if I click on one of the options, the wheel goes away, but the options dont do anything.
If I use the "New Command" option in NX9 Customization, and choose the NX Open and connect to the .exe file, it runs perfect. The problem is, we would have to manually make that button for each computer that uses the program. I cant find a way to transfer that button to another computer unless possibly with Roles, but I didnt look at that as we dont want to mess up each person's role.
I do wish I could just load the error info, but my hands are tied. Sorry.
RE: Journal or Macro to run .EXE files
To my understanding, this is actually not an error from NX, but is a "Microsoft.NET Framework" error.
The main error states.....
Unhandled exception has occurred in your application. If you click "continue", the application will ignore this error and attempt to continue. (It sometimes kicks me out of NX). If you click "Quit" this application will close immediately.
The type initializer for "XXXXXXX.Main" threw an exception.
Clicking on details there was a bunch of info, but this section seemed the important part to me.....
************** Exception Text **************
System.TypeInitializationException: The type initializer for XXXXXXX.Main' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'NXOpen, Version=9.0.0.19, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at XXXXXXXXX.Main..cctor()
--- End of inner exception stack trace ---
Does this help at all?
RE: Journal or Macro to run .EXE files
I do not know this language much but would I be right to assume that it is looking for the NX Open command and cant find it? Could the problem be that the code was written in NX8 or something, and since I am using NX9 and the NX Open command is in FILE / EXECUTE / NX Open, that the journal offered me is not looking for NX Open in the right place?
In the one in a million chance I am right, can someone tell me what to change in my journal code? (Which is what I posted around 8 posts above)
RE: Journal or Macro to run .EXE files
www.nxjournaling.com
RE: Journal or Macro to run .EXE files
The fact that if I manually run the .exe file and it works perfect, doesnt that say it does find all the needed files and the problem is somewhere in the Journal not working right?
RE: Journal or Macro to run .EXE files
Did You tried one of my suggestion, which I have posted on 5 January? If not, try it and write the results, especially my second proposition. It's look like You don't have access to file.
Do You have latest .net framework installed correctly? Try install .NET Framework 4.5.2.
Do You have admin rights? If yes, try "Disable UAC". see this link -> http://www.howtogeek.com/howto/windows-vista/disab...
Do You have installed "Microsoft visual studio C++"
With best regards
Michael
RE: Journal or Macro to run .EXE files
www.nxjournaling.com
RE: Journal or Macro to run .EXE files
2) Put this file on your local drive for example c:\ --------- This made no difference either
3) Try run journal with different .exe file for example some kind of installer or something. --------- I sent my journal to some old .exe files we do not use anymore. These seemed to try to run, but errored out for what looks to be reasons outside of the journal. Mainly as if we just dont have them set up to work anymore. This makes me believe it is the .exe file at fault. I will have a boss look for an .exe file we still use to test it farther.
4) Run this Journal on different NX (8.5?) or on different machine ---------- I cannot test this as we have zipped away all old NX8 files I am aware of. I will have to wait until a boss can hook me up.
If one of those methods will work, then We can find the answer. Please upload picture with error message.
So I will look further but I have to wait until bosses are in again (and have time). lol But I am not thinking there is something in how the .exe file is written that keeps it from communicating with the journal code or something strange like that.
Thanks. I will keep looking into this when I can.
RE: Journal or Macro to run .EXE files
www.nxjournaling.com
RE: Journal or Macro to run .EXE files
Cowski, it does open the text file.
Also
I copied the .dll files from that folder over with interesting results. It seems to start the .exe file with those coppied over, but the file then gives me a message saying I must first open a tool before continuing. But I already have a tool open and the exe file works if I run it manually. Does that make sense that it would now act like it wants to work, but doesnt recognize my NX has a tool open already?
RE: Journal or Macro to run .EXE files
www.nxjournaling.com