Re: A5 restart command?
I have attached a sample database that has a restart button to demonstrate how to terminate a running Alpha5 database and then restart it.
The restart button will call the VBScript "DB_Restart.vbs"
WARNING!
The script will do a forced process termination of the "Alpha5.exe" process. This is not a polite method to close down applications, unsaved work will be lost. Additional coding to protect data will need to be implemented prior to the vbscript call.
The vbscript works by terminating any running process that is called Alpha5.exe. If you have multiple databases all opened at the same time this script will terminate all of them (in theory, did not test that).
The script is not dynamic enough to be added to any database. You will need to change the varible strDB to the database file name that you want to open. It is possible to pass arguments to the script so that it knows who the calling database is. I did not take the time to code the arguments capability to the script.
Also the script file needs to be stored in the same folder as the .ADB file you wish to open.
I have attached a sample database that has a restart button to demonstrate how to terminate a running Alpha5 database and then restart it.
The restart button will call the VBScript "DB_Restart.vbs"
WARNING!
The script will do a forced process termination of the "Alpha5.exe" process. This is not a polite method to close down applications, unsaved work will be lost. Additional coding to protect data will need to be implemented prior to the vbscript call.
The vbscript works by terminating any running process that is called Alpha5.exe. If you have multiple databases all opened at the same time this script will terminate all of them (in theory, did not test that).
The script is not dynamic enough to be added to any database. You will need to change the varible strDB to the database file name that you want to open. It is possible to pass arguments to the script so that it knows who the calling database is. I did not take the time to code the arguments capability to the script.
Code:
strDB = "DB_Restart.adb"
Code:
'==================== ' ' NAME: DB_Restart.vbs ' ' AUTHOR: A. Schone ' ' SCRIPT TYPE: vbscript ' ' SUB TYPE: ' ' WSH VERSION: 2.0 ' ' COMMENT: ' ' ARGUMENTS: ' ' HISTORY: 05/17/2007 Creation ' ' Description: ' DB_Restart will terminate the Alpha5.exe process and then open the Alpha5 Database referenced by strDB. ' DB_Restart must reside in the same folder as the .ADB you wish to open '==================== Option Explicit 'On Error Resume Next ' Initialize vars Dim strDB Dim strPath 'Database to reopen strDB = "DB_Restart.adb" strPath = GetPath() + "/" + strDB EndAlpha5() 'Administrative tasks that need to be executed prior to re-opening of the database go here StartAlpha5() WScript.Quit(0) Sub EndAlpha5 Dim objWMIService, objProcess, colProcess Dim strComputer, strProcessKill strComputer = "." strProcessKill = "'alpha5.exe'" Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & strProcessKill ) For Each objProcess in colProcess objProcess.Terminate() Next End Sub Sub StartAlpha5 Dim objShell Set objShell = CreateObject("Wscript.Shell") objShell.Run strPath End Sub Function GetPath ' Return path to the current script DIM path path = WScript.ScriptFullName ' script file name GetPath = Left(path, InstrRev(path, "\")) End Function
Comment