Jump to content
Sign in to follow this  
StOngeCompany

Running Scripts With UAC On

Recommended Posts

StOngeCompany

Hello AutoIt forums,

I am wondering if there is any documentation or previous posts (I was unable to find any) that relate to running scripts under Windows 7 without turning UAC off. I've tried right-clicking and hitting Run as Administrator but that doesn't seem to do it. My script works in Windows XP, but not in Windows 7 because of a permissions issue. And yes, I did try it with #RequireAdmin at the top of the script. Here is my script:

#RequireAdmin

; Gather User Name

$user = InputBox("SOCO AutoCAD Installer", "Please enter your User Name.")

; Create Directory

DirCreate("C:\Program Files\AutoCAD 2010\SOCO")

; Copy Directories

DirCopy("H:\Installs\SOCAD_r7.0", "C:\Program Files\AutoCAD 2010\SOCO", 1)
DirCopy("C:\Program Files\AutoCAD 2010\SOCO\setup\support\acad_pgp", "C:\Users\" & $user & "\AppData\Local\AutoDesk\AutoCAD 2010\R16.2\enu\Support", 1)
DirCopy("C:\Program Files\AutoCAD 2010\SOCO\setup\support\acad_lsp", "C:\Program Files\AutoCAD 2010\Support", 1)
DirCopy("C:\Program Files\AutoCAD 2010\SOCO\setup\support\acad_cui", "C:\Users\" & $user & "\AppData\Local\AutoDesk\AutoCAD 2010\R16.2\enu\Support", 1)
DirCopy("C:\Program Files\AutoCAD 2010\SOCO\setup\support\ToolPalette", "C:\Users\" & $user & "\AppData\Local\AutoDesk\AutoCAD 2010\R16.2\enu\Support\ToolPalette", 1)
DirCopy("C:\Program Files\AutoCAD 2010\SOCO\setup\support\RegisteredTools", "C:\Users\" & $user & "\AppData\Local\AutoDesk\AutoCAD 2010\R16.2\enu\Support\RegisteredTools", 1)
DirCopy("C:\Program Files\AutoCAD 2010\SOCO\setup\support\Profiles", "C:\Users\" & $user & "\AppData\Local\AutoDesk\AutoCAD 2010\R16.2\enu\Support\Profiles", 1)
DirCopy("C:\Program Files\AutoCAD 2010\SOCO\plotters", "C:\Users\" & $user & "\AppData\Local\AutoDesk\AutoCAD 2010\R16.2\enu\Plotters", 1)

; Delete File

FileDelete("C:\Users\" & $user & "\AppData\Local\AutoDesk\AutoCAD 2010\R16.2\enu\Support\acad.mnr")

; Inform User of Completion

MsgBox(4096, "SOCO AutoCAD Installer", "SOCO AutoCAD installation complete!")

Is there something I am missing or is it not possible to run scripts under Windows 7 with UAC on?

Any help is greatly apppreciated.

Thanks,

DJ Berndt

Share this post


Link to post
Share on other sites
SKlocke

I also use the approach zorphnog mentions, compiled scripts as this tells AutoItWrapper to modify the manifest of the resulting executable.

When I tried using #RequireAdmin, there was a bug when UAC was turned off. But it worked fine with UAC turned on (this sounds like what you have).

So what happens with your script, does the DirCreate work, the first DirCopy where you do not use the $user?

Share this post


Link to post
Share on other sites
StOngeCompany

I added the following line of code to my script:

#AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator

It still fails to copy the files from the network drive to the Program Files directory. It creates the directory just fine, but doesn't do anything else. It's funny because the script runs to completion (the Message Box comes up at the end), but no files have been copied from the network. If I try to manually copy the files from the network drive in the Program Files directory, it asks for Administrative permissions. Is there anything I can do besides disabling the UAC?

Thanks for your help so far and for any future assistance!,

DJ Berndt

Share this post


Link to post
Share on other sites
SKlocke

H: is a network folder, mapped to the drive letter?

Try to give the network address, as in \\server\folder\. I think UAC introduces some kind of virtual user context, and if your folder mapping is executed on logon, it is not present when UAC switches user.

Also, you could look at the FileInstall function. This will include a target file during compile time and allow you to put it at a location during run time.

Share this post


Link to post
Share on other sites
StOngeCompany

I tried using \\server\share instead of the drive letter and it worked! :idea::):(

Thanks so much for your help everyone.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.