Highlighted
Super Contributor.
Super Contributor.
4257 views

Execute bat file from UFT

Jump to solution

I have a bat file, which starts a jar application. I try to execute it from UFT.

SystemUtil.Run "<path to mybat file>"

I execute action, but seemly nothing happen.

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Execute bat file from UFT

Jump to solution

OK, please try the following:

oShell.run "cmd /K ""C:\Program Files (x86)\MySoft\runbatch.bat"""

 

Two quatation marks one after the other will insert a single quatation mark into the line sent to execute.

Please let me know if it works.

Tsachi

View solution in original post

11 Replies
Highlighted
Knowledge Partner
Knowledge Partner

Re: Execute bat file from UFT

Jump to solution

Try this:

Dim oShell
Set oShell = CreateObject ("WSCript.shell")
oShell.run "cmd /K c:\mybatchfile.bat"
Set oShell = Nothing 

Mark Smith.

 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Execute bat file from UFT

Jump to solution

There are whitespaces in file path, could this maybe cause problems?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Execute bat file from UFT

Jump to solution

Hi, 

The below is working for me, it contains spaces as you can see.

SystemUtil.Run "C:\Temp\test bat\test.bat"

Can you share the line from the script?

Tsachi

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Execute bat file from UFT

Jump to solution

I use the same in a sperated Action in Test, but application isn't started.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Execute bat file from UFT

Jump to solution

Can you share the script line? 

Also, can you check it with a very simple bat file containing only two lines? just to try and isolate the issue. something like that in the bat file:

echo hello
pause

 

Highlighted
Super Contributor.
Super Contributor.

Re: Execute bat file from UFT

Jump to solution

It is working, a command prompt is opened. so problem is not in code.

EDIT: I waited for longer time and got following error message:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

It is strange too, that a browser window is opened during execution. I have another solutions, which are web based, but browser shouldn't be opened in this case.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Execute bat file from UFT

Jump to solution

Can you share the script line? 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Execute bat file from UFT

Jump to solution
oShell.run "cmd /K C:\Program Files (x86)\MySoft\runbatch.bat"
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Execute bat file from UFT

Jump to solution

OK, please try the following:

oShell.run "cmd /K ""C:\Program Files (x86)\MySoft\runbatch.bat"""

 

Two quatation marks one after the other will insert a single quatation mark into the line sent to execute.

Please let me know if it works.

Tsachi

View solution in original post

Highlighted
Super Contributor.
Super Contributor.

Re: Execute bat file from UFT

Jump to solution

Thanks, that is OK. Another solution is to specify program in UFT run settings and it will be executed automatically by UFT.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Execute bat file from UFT

Jump to solution

Hi, 

Great, thanks for confirming

Tsachi

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.