win32::job window attributes

C

Cameron

Hello All --

I am trying to launch a windows application either in the background
or with a minimized window using the following code:

my $job = Win32::Job->new;

$job->spawn(q{D:\Link32\Link32.exe}, q{Link32.exe}, {
stdout => 'output.txt',
stderr => 'error.txt',
window_attr => 'hidden'
});

The app is spawned successfully, but no matter how I try to redirect
stdout or set window_attr to hidden or minimized, it launches full screen.

Any thoughts or suggestions appreciated. I am not married to this module, so
if anyone has done this successfully in the past using something else, I'll
give it a try.

Thnx,

Cameron
 
M

MrReallyVeryNice

Hello Cameron,

Using your syntax, I was able to reproduce your problem. Of course, I don't
have a D:\Link32\Link32.exe on my computer so I used Notepad.exe. Notepad
would start but it would not be hidden or minimized. By the same token,
output.txt and error.txt were not created. I went back to the documentation
for Win32::Job and used the exact syntax. Here is a little sample that
worked for me on W2K:

==== Beginning script sample =====
use strict;
use warnings;
use Win32::Job;

my $job = Win32::Job->new();
my %opts=( window_attr=>'hidden',
stdout => 'output.txt',
stderr => 'error.txt');
$job->spawn(q{c:\winnt\system32\notepad.exe}, q{notepad "d:\temp\temp.txt"},
\%opts);
$job->run(10);

==== End script sample =====

As you noticed, the main difference with your script is that I defined the
hash %opts. I was then able to successfully minimize or hide the window. Of
course, output.txt and error.txt were also created successfully.

You might want to give it a try and see if the syntax documented for
Win32::Job does not fix your problem as well.

I would be great if you could report your future failure/success. :)
Additional questions are of course always welcome.

MrReallyVeryNice
 
C

Cameron

MrReallyVeryNice said:
Hello Cameron,

Using your syntax, I was able to reproduce your problem. Of course, I don't
have a D:\Link32\Link32.exe on my computer so I used Notepad.exe. Notepad
would start but it would not be hidden or minimized. By the same token,
output.txt and error.txt were not created. I went back to the documentation
for Win32::Job and used the exact syntax. Here is a little sample that
worked for me on W2K:

==== Beginning script sample =====
use strict;
use warnings;
use Win32::Job;

my $job = Win32::Job->new();
my %opts=( window_attr=>'hidden',
stdout => 'output.txt',
stderr => 'error.txt');
$job->spawn(q{c:\winnt\system32\notepad.exe}, q{notepad "d:\temp\temp.txt"},
\%opts);
$job->run(10);

==== End script sample =====

As you noticed, the main difference with your script is that I defined the
hash %opts. I was then able to successfully minimize or hide the window. Of
course, output.txt and error.txt were also created successfully.

You might want to give it a try and see if the syntax documented for
Win32::Job does not fix your problem as well.

I would be great if you could report your future failure/success. :)
Additional questions are of course always welcome.

MrReallyVeryNice

Hey Nice --

No go ..... I was able to reproduce your results with notepad as well,
but the application (a bastardized copy of wIntegrate used by car
dealers to access an old PICK system from Reynolds & Reynolds) still
refuses to open in a minimised window. Thanks for your input!

Cameron
 
M

MrReallyVeryNice

Hello again,

In addition to trying SendKeys as suggested by Petri, you might also
validate if your application (Link32.exe) has not been built/compiled with
the wrong switch. In which case no matter what you try, you will not be able
to minimize/hide it.

In the spirit of helping you debugging this problem, and certainly not
trying to drive you away from Perl, I would suggest that you take a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
tform/shell/reference/objects/ishelldispatch2/shellexecute.asp. If you
create a small VBScript, you will have a second data point. If you are
successful with a VBScript then you can decide to debug Win32::Job or try to
find another Perl module.

Here is a little untested sample program with Link32:
=== Beginning Script ===
Option Explicit
fnShellExecuteVB()

function fnShellExecuteVB()
dim objShell
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "Link32.exe", "", "D:\Link32", "open", 2
set objShell = nothing
end function
=== End Script ===

As earlier, please report your failures/successes.
MrReallyVeryNice
 
C

Cameron

MrReallyVeryNice said:
Hello again,

In addition to trying SendKeys as suggested by Petri, you might also
validate if your application (Link32.exe) has not been built/compiled with
the wrong switch. In which case no matter what you try, you will not be able
to minimize/hide it.

In the spirit of helping you debugging this problem, and certainly not
trying to drive you away from Perl, I would suggest that you take a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
tform/shell/reference/objects/ishelldispatch2/shellexecute.asp. If you
create a small VBScript, you will have a second data point. If you are
successful with a VBScript then you can decide to debug Win32::Job or try to
find another Perl module.

Here is a little untested sample program with Link32:
=== Beginning Script ===
Option Explicit
fnShellExecuteVB()

function fnShellExecuteVB()
dim objShell
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "Link32.exe", "", "D:\Link32", "open", 2
set objShell = nothing
end function
=== End Script ===

As earlier, please report your failures/successes.
MrReallyVeryNice


Thanks to both of you ..... what I finally decoded to do was to
execute the
wIntegrate scripting command "Session Show 3" as soon as the app opens
which basically accomplishes the same thing. I'm a bit disapointed
that I couldn't do it with Perl, but I can waste too much time on it.

Cheers,

Cameron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top