Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

VBS script to quit an external application?

Community Expert ,
Nov 06, 2018 Nov 06, 2018

I may be in need of a way to quit an external application during the execution of a .jsx script in illustrator. Specifically acrobat. I've written some code that saves the current document as a PDF, but I'm finding that on windows, an error presents itself when attempting to save a pdf that is already open in Acrobat.

Anybody with VBS experience have any advice to share? I've never written VBS and don't have a windows machine to test on.. so the more complete the advice the better.

Thanks in advance.

TOPICS
Scripting
3.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 07, 2018 Nov 07, 2018

I looked here for some examples

Close an application using VBScript - Stack Overflow

this one worked for me to close Reader on Windows 10

'attempt to quit Reader,

'Option Explicit 'all variables must be declared

Err.Clear

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _

    ("Select * from Win32_Process Where Name = 'AcroRd32.exe'")

For Each objProcess i

...
Translate
Adobe
Community Expert ,
Nov 07, 2018 Nov 07, 2018

I looked here for some examples

Close an application using VBScript - Stack Overflow

this one worked for me to close Reader on Windows 10

'attempt to quit Reader,

'Option Explicit 'all variables must be declared

Err.Clear

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _

    ("Select * from Win32_Process Where Name = 'AcroRd32.exe'")

For Each objProcess in colProcessList

    objProcess.Terminate()

    If (Err.number <> 0) Then

                Err.Clear

    End If

Next

as with js, copy the script and paste it into a text editor and give it a vbs extension. Double click to execute or use file.execute() in your jsx

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2018 Nov 08, 2018
LATEST

awesome, thanks carlos!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines