Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Spawing Win32 Processes

by akm2 (Scribe)
on Aug 17, 2001 at 20:00 UTC ( [id://105717]=perlquestion: print w/replies, xml ) Need Help??

akm2 has asked for the wisdom of the Perl Monks concerning the following question:

I run the following Perl code when a certain user loggs on to my Windows 2000 Server machine.

#!/usr/bin/perl open(DBFILE,"<Y:\\tsweb.log")|| die; while ($line=<DBFILE>) { chomp $line; if ($line =~ m/|/) { $myline = $line; } } ($TimeandDateStamp, $ip, $appid, $apppath, $extra) = split(/\|/, $myli +ne); system "start /max /w $apppath"; system "logoff"; exit;

Everything works great untill the script process these lines of code:

system "start /max /w $apppath"; system "logoff";

When those lines of code are proccessed, a Command Prompt is launched. In this case that is a security risk for me.

I thought I could use the Win32::Process module to solve the problem of the CammandPrompt launching, but I can't get the module to work right.

Can somebody give me an example code snippet using this module to do what I need, or tell me a better way?

Thanks in advance for any advise!

Andrew Kenton Mitchell
Andrew@AndrewKMitchell.com

Replies are listed 'Best First'.
Re: Spawing Win32 Processes
by joefission (Monk) on Aug 17, 2001 at 22:22 UTC
    test.pl:

    use Win32::Process; use strict; my $ProcessObj; Win32::Process::Create($ProcessObj, "c:/perl/bin/perl.exe","perl test1 +.pl", 0, DETACHED_PROCESS, "."); my $pid = $ProcessObj->GetProcessID(); print "$pid\n";
    test1.pl:
    open(FILE,">c:/tada.txt"); print FILE "hello\n"; close FILE;

    Alternatively, you could try start /B which is supposed to start an application without starting a new window.

      If you want no window to pop up you can replace DETACHED_PROCESS in the example above with (DETACHED_PROCESS | CREATE_NO_WINDOW) which I've successfully used to supress an app that insisted on spawning a new console window. Seems output from the supressed app (if there is any) gets passed to STDERR.

      If you don't want that but want console interaction of some sort, look at the Win32::Console module.

      Glenn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://105717]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-29 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found