Link to home
Start Free TrialLog in
Avatar of qeng
qeng

asked on

VBScript - How to Load an App Targeting a Specific File - Problems with .ShellExecute Syntax

In a VB Script, I can get this line of code to open up my targeted app (assume for illustration purposes that 'app = "C:\Program Files (x86)\SomeAppFolder\SomeApp.exe":

     objShell.ShellExecute app

What's the syntax to add to the above line of code to open the 'app' with a target file (e.g. how to I get 'app' to execute on say  ' f = "C:\Users\MyName\Desktop\testfile.txt" '?

If used different variations such as the following with no success:
     
     objShell.ShellExecute app, , f, "open"  ' ONLY LOADS the app ... not the app with file 'f' already loaded ready for use

Thx
Avatar of Professor J
Professor J

objShell.ShellExecute "notepad.exe", "C:\Users\MyName\Desktop\testfile.txt", "", "open", 1

For details on https://docs.microsoft.com/en-us/windows/desktop/shell/shell-shellexecute
Note: Your "app" must support command line arguments.
Avatar of qeng

ASKER

@ ProfessorJimJam:  

Thx that syntax is correct (I had tried it previously with CustomUIEditor.exe with fully qualified path but received a File Not Found on the file I was trying to open with CustomUIEditor.).

@FabriceLambert:  

You may have identified the root cause of my issue (or I don't know which switches/syntax to use to pass a file argument for 'app' to open).  

How can I find out if CustomUIEditor.exe supports command line arguments.  

I've tried looking in the MS Custom UI XML Markup Specification but didn't spot anything relating to Command Line Arguments (might have missed it).

In attempting to get a list of available command line arguments, I've tried adding " /?" to the fully developed path URL for CustomUIEditor.exe but I get the error in the attached screengrab.  Not sure if the syntax I'm trying in trying to specify the " /?" switch is correct either.

Thx
CustomUIError.png
How can I find out if CustomUIEditor.exe supports command line arguments.
Looks in the application's documentation, or ask the developpers.
If it wasn't designed with command line arguments support, there is nothing you can do.

Searching for "CustomUIEditor command line" on google yelded no relevant result.
Guess it does not support command line arguments.
Avatar of qeng

ASKER

@Fabrice Lambert:  

Thx.  No luck with documentation yet.

I'm trying a workaround with SENDKeys.

I can get VBScript to open up a fresh window with CustomUIEditor.exe just fine with

set objShell = CreateObject("Shell.Application")appPath = "C:\Program Files (x86)\CustomUIEditor\"
appName = "CustomUIEditor.exe"
app = appPath & appName
objShell.ShellExecute app

with the app open, if I manually press the 'ALT' Key then the 'F' key, I can toggle the file menu.

How can I send a SENDKEYS to this app (ie the active window) created by the above VBscript? (I keep getting Object doesn't support this property or method; I'm a novice in this area so may be trying incorrect syntax).

It seems to me that once the app is loaded, I'm simply trying to interact with a basic window (in Win10).
I'm trying a workaround with SENDKeys.
Better shoot yourself in the foot than doing that !!
You have no way to ensure the application will be displayed and remain on top of all other Windows.
Avatar of qeng

ASKER

@FabriceLambert:

I realize this is a bit of a hack (though this VBScript I'm trying to get working is for my own use so I don't mind if it's not robust, as long as I can get it to work).

Having loaded the app (ie window appears), what would be the command to simply Echo the name of the active window?  I could start with that.

Presently I don't understand (know) the syntax to Echo the loaded app's Window Title in this VBScript.

Merci Fabrice
Afraid I cannot help further.
Avatar of qeng

ASKER

@Fabrice Lambert:

Thx for your input just the same.  It's tweaking me to look in a different area.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.