Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Write file in Windows Programs folder

by soonix (Abbot)
on Jan 24, 2018 at 22:36 UTC ( #1207872=note: print w/replies, xml ) Need Help??


in reply to Write file in Windows Programs folder

  • The "real" name of that folder is C:\Program Files (x86), the national language variant is a Junction Point
  • On my system, the name is available to Perl via %ENV, more specifically in $ENV{ProgramFiles(x86)} (no spaces in that name, contains folder name including drive letter and all)
  • Depending on system configuration, not even an Admin User can simply write there → UAC

Replies are listed 'Best First'.
Re^2: Write file in Windows Programs folder
by papidave (Pilgrim) on Jan 25, 2018 at 04:16 UTC
    Before you panic about UAC, you may want to verify that this isn't a simple case of trying to run from a non-admin account. Right-click on the command prompt icon, RunAs Administrator, and launch your Perl script from there. If it works as an admin user, you can probably code a test for that and tell the user what to do if it fails. (I do most of my Perl in Linux, so I'm probably not the best person to help you with that part).

    If open my $fh, '>', $path or die "Can't open $path: $!\n"; still fails on your programs dir when run as an admin, then you can panic.

      No solution worked. I can not write/copy in the Programs folder. I packed the script in an exe in order to run it as Administrator (do not know how to run a script as Administrator), but nothing is written in the Programs folder.

      However, there are some programs installed in the same folder doing automatic updates, which I guess means automatic replace some files in the installation folder. I am a bit scared of looking into the "writing rights" matter. Just seems to complicated for me.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1207872]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2020-04-06 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (41 votes). Check out past polls.

    Notices?