2

I'm new at batch and I'm trying to make a simple script that moves an executable from a network drive to a certain folder in Program Files. The script will be executed by people who have admin on their computer. The exe cannot be execute elsewhere because it needs all necessary library files in that specific folder in Program Files(SDK limitation).

Manually, I can't directly drag the exe from the network drive into the folder because I get a warning and then an error. The warning says: "You'll need to provide administrator permission to copy this folder". I do, so I click continue. Then I get an error saying that the network drive "X:" does not exist. However, if I first copy the exe from the network drive to Downloads (local), and then cut and paste from Downloads to the folder in Program Files, I get the same warning but it moves the file after I click on continue.

Seeing how I could not manually do a straight copy over, I made a simple batch file that copies my second approach:

COPY "X:\Path\to\program.exe" "C:\Users\Me\Downloads\"

MOVE /-y "C:\Users\Me\Downloads\program.exe" "C:\Program Files\Company\SDK\"

The first line works fine. The second line returns an access denied. Seeing how I was able to access Program Files, is there a way to grant shell the same access. This batch script will be executed by people who only know the basics of computing so I was hoping the script does all the work and they just need to double click it.

user1275094
  • 125
  • 2
  • 2
  • 7
  • There's something here that looks like it makes the script execute as administrator http://stackoverflow.com/questions/1894967/how-to-request-administrator-access-inside-a-batch-file – Paul Sellars Jul 05 '13 at 14:49
  • You have to run it as Administratos as Paul sais. ;) – Seazoux Jul 05 '13 at 14:50
  • Thanks for the suggestion Paul. I've tried what was posted but when I execute the script, and grant it admin access, the screen flickers and goes away. Nothing changes. It feels like it just jumps over my code and exits. :/ – user1275094 Jul 05 '13 at 15:27
  • Please explain clearer, what's going on with the screen. Do you need a new one? – Endoro Jul 05 '13 at 15:29
  • No problem. So far I copied the chunk of code from the link Paul (minus the ) part. After the ":---" line I have my copy and move commands. When I double click on the batch (it's on the network drive), the cmd window pops up. Access Denied is printed before it prompts me to grant access. Once I click on yes, the cmd window exits – user1275094 Jul 05 '13 at 15:39
  • change the single quotes to double quotes. – Endoro Jul 05 '13 at 16:21
  • You mean at the "if '%errorlevel%' == '0' (" part? I did and I get the exact same result. – user1275094 Jul 05 '13 at 16:36
  • any luck anyone? it seems program files won't let me copy it via batch. but it lets me do it manually. I first copy to desktop, then to program files. but this is my automated test script, I do not want to do it manually. – hamish Nov 28 '15 at 22:32

1 Answers1

0

You can not copy a file from network to your "Program Files"
Copy it in desktop then copy from "desktop" to "program files"

Ashish
  • 72
  • 4