in reply to Re: Restarting a Perl script on Windows 10
in thread Restarting a Perl script on Windows 10

What do you get with Win32::Unicode::Process

use Win32::Unicode::Process; execW $^X, '-f', File::Spec->rel2abs(__FILE__);

What do you get with system_detached?

What do you get for reg query "HKCU\Software\Microsoft\Command Processor"? or reg query "HKLM\Software\Microsoft\Command Processor"

Replies are listed 'Best First'.
Re^3: Restarting a Perl script on Windows 10
by petro4213 (Acolyte) on Sep 23, 2019 at 08:12 UTC
    Hi, thanks for your hints.

    Your suggestion with Win32::Unicode::Process restarts the program without having to press Enter, but doesn't exit the original instance.

    The keys in the registry are the same as on my Windows 7 machine:
    CompletionChar 0x00000009 DefaultColor 0x00000000 EnableExtensions 0x00000001 PathCompletionChar 0x00000009
    I don't understand what you mean with system_detached
      Use system_detached...exit...instead of exec and report what happens
      execW doesnt exit? What if you call exit afterwards? Does the program memory increase?

        Ok here is a patch for Win32::Unicode::Process

        sub execW { my $pi = Win32::Unicode::Process::_create_process(@_) or return 1; close_handle($pi->{thread_handle}); close_handle($pi->{process_handle}); exit 0; ## the end } sub _create_process { @_ or return; use Win32::ShellQuote(); my( $program ) = @_; my $commandline = utf8_to_utf16( Win32::ShellQuote::quote_system_s +tring( @_ ) ).NULL; return create_process( $program, $commandline ); }