use strict; use warnings; use Win32::API; my $getcmdline = Win32::API->new( 'kernel32.dll', 'GetCommandLine', [], 'P' ) or die "error: Win32::API GetCommandLine: $^E"; my $cmdline = pack 'Z*', $getcmdline->Call(); $cmdline =~ tr/\0//d; # remove any NULLs left over from pack Z* $cmdline =~ s/\s+$//; # remove trailing white space print "cmdline=$cmdline:\n";