0

I am trying to install 7-Zip if its already not installed in my Win7 systems using a Perl script.

# Check if 7-Zip is installed or Not.

if (!(-e "C:\\Program Files\\7-Zip")){
    print "\n 7-Zip is not installed. Downloading ... \n"
    system("wget http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.20/7z920.exe?r=&ts=1392082197&use_mirror=softlayer-dal");
    print "\n Installing.. \n";
    system("7z920.exe /S /D=\"C:\Program Files\7-Zip\"");
}

It is downloading the file I need (7z920.exe) to the PWD, but it doesn't install. I keep getting the command line error, "Access Denied". Even if I run the script in Administrator mode on command line.

In fact, if I simply go the system path were 7z920.exe on command line and attempt to call the .EXE, i get the same denied error. It won't install. But if I click on it from the folder, it allows me to install it?! Why is that I may double-click and install from folder, but cannot call the executable from the same path from command line and not install it?

C:\>7z920.exe /S /D="C:\Program Files\7-Zip"
Access is denied.

Can you help me? How do I install this using my script? or from a batch file?

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
YouHaveaBigEgo
  • 220
  • 6
  • 13

1 Answers1

0

When I run that wget command, I get a file called 7z920.exe@r=&ts=1392082197&use_mirror=softlayer-dal. So I would recommend

  1. Use wget's -O option to force the downloaded file to have the filename you want.

    wget -O 7z920.exe http://downloads.sourceforge.net/project/...
    
  2. I don't know what's in your PATH, so precede your command with the current path.

    system(".\\7z920.exe /S /D=...");
    
  3. Be careful about how you escape special characters in Perl inside double quotes. Try one of:

    system(".\\7z920.exe /S /D=\"C:\\Program Files\\7-Zip\"");
    system('.\7z920.exe /S /D="C:\Program Files\7-Zip"');
    
mob
  • 117,087
  • 18
  • 149
  • 283