Author Topic: Batch.bat file control plug-in  (Read 4597 times)

onthecuttingedge2005

  • Guest
Batch.bat file control plug-in
« on: March 22, 2009, 03:10:02 pm »
This plug-in allows a user to run batch files on command.

make sure that your .bat files are in the Ultra Hal Assistant 6 folder for the plug-in to work. because the vbscript will call from where the plug-in resides.

Code: [Select]
Rem Type=Plugin
Rem Name=Batch File Controller
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
Rem Host=Assistant

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = "Program Controller; PROGRAM NAME: can be anyname like; LIGHTS, APPLICATION NAME: Light.bat <- include .bat extension"
    lblPlugin(0).Move 120, 10, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
End Sub

Rem PLUGIN: PRE-PROCESS
    'The preceding comment is actually a plug-in directive for
    'the Ultra Hal host application. It allows for code snippets
    'to be inserted here on-the-fly based on user configuration.
   
    If HalBrain.CheckTableExistence("BatchFileListings") = False Then
            HalBrain.CreateTable "BatchFileListings", "TopicSearch", ""
        End If

Set MyBatchApp = CreateObject("WScript.Shell")

'Example; create a batch file path to a batch file and give it a name the computer will use to identify it and run it.
'Batch File Name: Lights, Batch File Path: C:Lights.bat

If BatchFileName = "" Then BatchFileName = HalBrain.SearchPattern(InputString, "*PROGRAM NAME: *, APPLICATION NAME: *", 2)
If BatchFilePath = "" Then BatchFilePath = HalBrain.SearchPattern(InputString, "*PROGRAM NAME: *, APPLICATION NAME: *", 3)

If BatchFileName <> "" And BatchFilePath <> "" Then
HalBrain.AddToTable "BatchFileListings", "TopicSearch", Trim(BatchFileName), Trim(LCase(BatchFilePath))
UltraHal = "I have mapped out this specific batch file to run on command, just say: run, start, begin, turn on, turn off along with the batch file name you gave me and I will run the batch file for you."
Exit Function
End If

RunABatch = HalBrain.TopicSearch(InputString, "BatchFileListings")
RunABatch = Trim(RunABatch)

If RunBatProg = "" Then RunBatProg = False
If InStr(1, InputString, "run", vbTextCompare) > 0 Then RunBatProg = True
If InStr(1, InputString, "start", vbTextCompare) > 0 Then RunBatProg = True
If InStr(1, InputString, "begin", vbTextCompare) > 0 Then RunBatProg = True
If InStr(1, InputString, "turn on", vbTextCompare) > 0 Then RunBatProg = True
If InStr(1, InputString, "turn off", vbTextCompare) > 0 Then RunBatProg = True

If RunBatProg = True And RunABatch <> "" Then
HalBrain.ReadOnlyMode = True
MyBatchApp.Run "cmd /C Start " & RunABatch

UltraHal = "I will run the program for you."
Exit Function
End If
 
If RunBatProg = True Then HalBrain.ReadOnlyMode = True
If BatchFileName <> "" And BatchFilePath <> "" Then HalBrain.ReadOnlyMode = True

Jerry[8D]
« Last Edit: April 27, 2009, 01:37:31 am by onthecuttingedge2005 »

onthecuttingedge2005

  • Guest
Batch.bat file control plug-in
« Reply #1 on: March 22, 2009, 03:16:16 pm »
just copy and paste the code into a text file and save as BatchControl.uhp
in the "C:\Program Files\Zabaware\Ultra Hal Assistant 6" folder then choose the plug-in from HAL'S option window.

you can also edit the batch file names and paths in the "BatchFileList" table in the brain editor in case you would rather do it manually.

Jerry[8D]
« Last Edit: March 22, 2009, 03:24:28 pm by onthecuttingedge2005 »

jackfarrel

  • Newbie
  • *
  • Posts: 29
    • View Profile
Batch.bat file control plug-in
« Reply #2 on: April 24, 2009, 11:22:50 pm »
Wonderful plugin but I can't get it work for the life of me, I've tried it on many systems now. For some reason it opens my command prompt and closes it out quickly, without executing anything. I have tried many angles and many things with the batch files and my system, but your plugin so far has not worked, so I think there is something in the plug. Please advise. I'm eager to get this going because having the power to open batch files like this opens so many possibilities!!
 

onthecuttingedge2005

  • Guest
Batch.bat file control plug-in
« Reply #3 on: April 27, 2009, 01:31:37 am »
quote:
Originally posted by jackfarrel

Wonderful plugin but I can't get it work for the life of me, I've tried it on many systems now. For some reason it opens my command prompt and closes it out quickly, without executing anything. I have tried many angles and many things with the batch files and my system, but your plugin so far has not worked, so I think there is something in the plug. Please advise. I'm eager to get this going because having the power to open batch files like this opens so many possibilities!!



Hi Jack.

please see your other post.

Jerry