Notifications
Clear all

[Closed] CopyFile to Program Files Directory

I’m working on a script which needs to copy a DLX file into the “C:\Program Files\Autodesk\3dsmax 2013\Plugins” folder, CopyFile() doesn’t work as you need admin rights to copy a file into the program files folder. Does anyone know a way to make it happen? I’m assuming it’ll put up a password prompt?

6 Replies

i’m sure you can do it with .NET. take a look at DirectorySecurity class

If you create a .exe installer, there are a free tools for that, Windows somehow isn’t as restrictive as when a non-installer application (3dsmax) tries to put files in system folders.
It’s also easy to detect installed max versions with installers.
I found that route much more robust than maxscript installers.
I can put up an example, if there is interest.

How about forging a dos command sequence which elevates using Dos’s “runas” , does the copying and launch that command sequence using maxscript’s “DOSCommand <command_string>” ?
Might become tricky feeding runas with the dos command sequence i guess

.NET looks like the better way though. Especially when you want to have some elegant password input prompt …

If you need to do it from 3dsmax then – some ways to do it is:

  • user has to run 3dsmax as administrator (right-click->run as administrator).
  • User has to turn off user access control (I do not recommend this, but still it’s a option).
  • user can set 3dsmax .exe properties so that it always has access to read\write files to the various directories – (right-click 3dsmax.exe, properties, security tab).

One good option is to have your plugin load from another folder which is read\writeable by the user, for example a folder under ‘documents and settings’, you can add the path to 3dsmax.ini by code\script.

(look in : 3dsmax menu on top of screen->customize->configure system paths -> 3rd party tab).
There a user can add other folders to load plugins from (and you can add the entry by code too for the user).

What I do is create a bat file that has the “copy” operations in it. And them from manuscript I launch the bat file through nircmdc.exe which has an elevate command.

.NET seems much more elegant and it would be great to know how you do it!

You probably know that you can use dotnet to fire a commandline process via xcopy or robocopy, but I think you’ll always be fighting UAC.