Welcome, Guest. Please login or register.
Did you miss your activation email?
June 21, 2018, 03:09:02 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  Mach SDK plugin questions and answers.
| | |-+  Finished Plugins for Download
| | | |-+  Plugin to run script on Shutdown
Pages: 1 2 »   Go Down
Print
Author Topic: Plugin to run script on Shutdown  (Read 2154 times)
0 Members and 1 Guest are viewing this topic.
X-TRA78
Active Member

Offline Offline

Posts: 7


View Profile
« on: January 06, 2018, 08:05:30 AM »

Hello,

For my new ScreenSet (Sinumerik OP47), i have written a plugin with which one can execute a script (*. vbs or * hta) when Mach3 is shut down.
Maybe someone else need such a function and that's why I uploaded the plugin.

The Script should be stored in the following location.:
{Mach3InstallPath}\Macros\{Profile}\Shutdown(x).(vbs|hta)
It will look first for Shutdown(x).hta and if Not found, then Shutdown(x).vbs.

You can use multiple shutdown scripts, e.g. one to shut down Windows and one to modify XML-Profile and reboot Mach3 etc.

1.Shutdown.vbs
2.Shutdown2.vbs
3.Shutdown3.vbs
4....

The number of the shutdown script (x), can be set by using the "SetShutdownScriptNum (wNum)" subroutine.

Code:
Declare Sub SetShutdownScriptNum Lib "ShutdownScript" (ByVal Num As Integer)

The plugin does not need to be activated via the "config Plugins" menu.


currently two parameters are passed to the shutdown script.
Parameter 1 = path of Mach3 install folder
Parameter 2 = profile name

* ShutDownScript.m3p (16 KB - downloaded 89 times.)

* PluginNeedNoActivation.png (19.74 KB, 504x347 - viewed 145 times.)
« Last Edit: January 06, 2018, 08:10:26 AM by X-TRA78 » Logged
X-TRA78
Active Member

Offline Offline

Posts: 7


View Profile
« Reply #1 on: January 06, 2018, 08:29:30 AM »

Example for Shutdown.vbs to get the Params and wait until Mach3 shut down is finish.

Code:

Dim iCount
Dim iArg
Dim sProfileName
Dim sMach3Path

iCount = wScript.Arguments.Count

if iCount >= 2 then

sMach3Path = wScript.Arguments(0)
sProfileName = wScript.Arguments(1)

Else
' ....
End If

Set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='mach3.exe'"
set cproc=svc.execquery(sQuery)
iniproc=cproc.count   

Do While iniproc = 1
    wscript.sleep 200
    set svc=getobject("winmgmts:root\cimv2")
    sQuery="select * from win32_process where name='mach3.exe'"
    set cproc=svc.execquery(sQuery)
    iniproc=cproc.count
Loop

set cproc=nothing
set svc=nothing

' Mach3 has been fully shut down.
' now modify XML-Profile or something else.
« Last Edit: January 06, 2018, 08:31:03 AM by X-TRA78 » Logged
Tweakie.CNC
CNC is only limited by our imagination.
Global Moderator
*
Offline Offline

Posts: 7,264


Super Kitty


View Profile WWW
« Reply #2 on: January 06, 2018, 11:08:12 AM »

That sounds very interesting, thanks for sharing.

Tweakie.
Logged

Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
X-TRA78
Active Member

Offline Offline

Posts: 7


View Profile
« Reply #3 on: January 08, 2018, 03:55:33 AM »

Hello,

here is a new version of the plugin (v0.2.2.106).
I've adjusted the search paths for the script and added a new feature that lets you set the search path for the script.
In addition, the name of the first ScreenSet will be passed to the script.

The following function can now be used to set the search path
Code:
Declare Sub SetShutdownScriptPath Lib "ShutdownScript" (ByVal szPath As String)

SetShutdownScriptPath "C:\Mach3\ScreenSetMacros\Test.set\Scripts"

if no search path has been set, it is first searched in dir "{Mach3Path}\Macros\{Profile}\" for the file and then in dir "{Mach3Path}\ScreenSetMacros\{ScreenSetName}.set\"

These three parameters are now passed to the script:

Parameter 1 = path of Mach3 install folder
Parameter 2 = profile name
Parameter 3 = main screenset name (currently only first loaded ScreenSet)

* ShutDownScript_v022106.zip (9.35 KB - downloaded 47 times.)
Logged
Esteb
Active Member

Offline Offline

Posts: 8


View Profile
« Reply #4 on: April 27, 2018, 05:50:59 PM »

Hi, can u show us your Sinumerik screenset please?
Logged
X-TRA78
Active Member

Offline Offline

Posts: 7


View Profile
« Reply #5 on: April 30, 2018, 12:00:55 AM »

unfortunately, the ScreenSet isn't finished yet  Sad
but i'm still working on it.
Logged
Esteb
Active Member

Offline Offline

Posts: 8


View Profile
« Reply #6 on: May 04, 2018, 09:19:37 PM »

Hi again, I hope you can finish it soon, I'm starting to work on a PC in kiosk mode to run Mach3, trying to hide the title bar, buttons, and other things like turn off the whole machine with the help of your script.

I'll ask you something, when the script is executed (closing Mach3) a popup message appears asking wich user would execute this program, trying to protect my PC from malicious software. I guess it's a permissions problem, don't?

I really don't have much experience with VB, so please, could you help me?

I just need a good scritp to turn off my pc.

Thanks!!
Logged
X-TRA78
Active Member

Offline Offline

Posts: 7


View Profile
« Reply #7 on: May 07, 2018, 02:24:58 PM »

I think it's the UAC of Windows.

You must logged on with an account that belongs to the "Admin Group" and set UAC to a lower level.

I personly would never connect the computer with Mach3 to the Internet,
otherwise you will need an antivirus program which can interfere the run of Mach3.

All my control PCs for my machines are not connected to the internet
and Mach3 is installed with an administrator account and UAC is disabled.

I hope I could help you a little bit.
best regards

X-TRA78
Logged
Esteb
Active Member

Offline Offline

Posts: 8


View Profile
« Reply #8 on: May 07, 2018, 06:50:43 PM »

Yeah, but is Windows XP SP3, there is not UAC

By the way, where I can find VB scripts examples to start to learn?

thanx!
Logged
X-TRA78
Active Member

Offline Offline

Posts: 7


View Profile
« Reply #9 on: May 09, 2018, 10:12:32 AM »

Hello,

Quote
Yeah, but is Windows XP SP3, there is not UAC

Did you logged on with an administrator account?

Quote
By the way, where I can find VB scripts examples to start to learn?

there are many Sites to learn VBScript, for example http://www.herongyang.com/VBScript/index.html
or https://www.youtube.com/watch?v=tnXR3Gwr8w8&list=PLyGqUe6Oa_5GCc-hVJ-Nt06OVGuTc0mS9

Logged
Pages: 1 2 »   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!