Author Topic: How to launch a batch file from VBScript under EA  (Read 274 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6565
  • Karma: +132/-97
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
How to launch a batch file from VBScript under EA
« on: January 10, 2019, 04:52:36 pm »
We have a VBScript that generates Snapshots of the Production repository into .EAP files using the Project Transfer method.
However, as we know, you need to do a compress after the transfer you need to compact the resulting .eap file to make it usable.

We run a batch file after the scripting to achieve the compaction.  The lines in the batch file are similar to:
start /min /wait "C:\Program Files (x86)\Microsoft Office\Office15\MSAccess.exe" "Some.mdb" /Compact

I've tried a number of mechanisms to launch the batch file from the VBScript so the compaction can be done in-line.  However, I've had no success.  Can some kind soul provide the "secret sauce" to achieve this?

Code: [Select]
dim oWindowsShell, sCommand
sCommand = "start /min /wait ""C:\Program Files (x86)\Microsoft Office\Office15\MSAccess.exe"" ""Some.mdb"" /Compact"
set oWindowsShell = CreateObject("WScript.Shell")
Session.Output(sCommand)
Dim iResult
iResult = oWindowsShell.Run (sCommand,1,true)

set oWindowsShell = nothing
Generates a scripting error at the Run line.

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Arshad

  • EA User
  • **
  • Posts: 176
  • Karma: +10/-1
    • View Profile
Re: How to launch a batch file from VBScript under EA
« Reply #1 on: January 10, 2019, 05:15:38 pm »
Hi Paolo

Try setting the directory

Code: [Select]

Set oShell = CreateObject ("WScript.Shell")
      oShell.CurrentDirectory = "C:\Users\Test"   'Path of the batch file
      oShell.Run "TestBatch.CMD"

Below is the command which I had in my batch file
//start chrome https://www.google.co.in

HTH
Arshad
« Last Edit: January 10, 2019, 05:21:13 pm by Arshad »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6565
  • Karma: +132/-97
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to launch a batch file from VBScript under EA
« Reply #2 on: January 11, 2019, 11:42:36 am »
Hi Paolo

Try setting the directory

Code: [Select]

Set oShell = CreateObject ("WScript.Shell")
      oShell.CurrentDirectory = "C:\Users\Test"   'Path of the batch file
      oShell.Run "TestBatch.CMD"

Below is the command which I had in my batch file
//start chrome https://www.google.co.in

HTH
Arshad
Thanks, Arshad!

Got it going now.

A couple of observations:
In my code, I was trying to run the command directly from the script, not with a batch file.  (Bad move)

There seems to be an issue with spaces in the process.  The usual methods for dealing with spaces didn't work for me.  Anyhow, I solved my issues with some judicious renaming.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!