Author Topic: Network share/ script  (Read 6034 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Network share/ script
« Reply #15 on: September 18, 2009, 04:48:37 PM »
I concur.

Having gazed upon the navel, I would suggest using the xcopy command I posted above, unless you're a ROBOCOPY ninja.

Chumplybum

  • Newt
  • Posts: 97
Re: Network share/ script
« Reply #16 on: September 20, 2009, 05:48:56 PM »
i use a loading dll, which checks the network for an updated dll (using the timestamp) against the files on the users machine. The process is as follows...

1. an msi installs the loading dll on the users machine, registers the dll for demand loading and adds 2 other registry keys... one for the network location and one for the local computer install location
2. on autocad startup, the loading dll gets loaded into cad and runs the check, comparing the network files against the local machine files
3. if a change is found the new file gets copied to the local machine and loaded, if not then the local copy gets loaded
4. any changes required of the loading dll get updated via a new msi package


HTH

cheers, Mark

Excellent! Never thought of this way. Seems to answer all the questions I have had. One question though: With my program, I sync'd more than
the standard assemblies; I checked the versions, datetimes and checksums of over 15000 support files, including templates, block libraries etc.
It may be too much of a performance hit on AutoCAD startup to check this many. Do you do this?



mcarson, all of the support files (besides the dlls) are stored on the network drive and accessed from there. So no, its just the dlls that are checked / copied... i'm not sure why you'd want a local copy of all the other support files? users working from home perhaps???

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Network share/ script
« Reply #17 on: September 21, 2009, 02:25:23 PM »
Thanks Glenn.  I was hoping it would be pretty simple.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
Re: Network share/ script
« Reply #18 on: September 21, 2009, 03:30:46 PM »
You're welcome as always Duh. It can be as simple or as complex as you like. Myself, I subscribe to the K.I.S.S. principle which is almost always correct.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Network share/ script
« Reply #19 on: September 22, 2009, 05:30:16 PM »
So far I have a bit of every bodies version that seems to be working.
Mick's idea seemed the easiest for me, but then I realized quite a few people start their acad from windows explorer.
So I have 2 dlls autoloading via the registry. The first one just checks for the most up to date version, and updates the file main dll if reqd. The second one is the main dll.
The keys are called startup and startup2. Startup2 fires after startup so the file replacement isn't a problem.
Not a lot of code really, below makes the Startup.dll.  You need to netload it once to set the registry keys.
It's definately not as good as the other solutions offered.  Thanks again for the help



Code: [Select]
using System.IO;
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using acadApp=Autodesk.AutoCAD.ApplicationServices.Application;
using Microsoft.Win32;


[assembly: ExtensionApplication(typeof(Autodesk.AutoCAD.AutoCAD_2010_plug_in1.MyPlugin))]

namespace Autodesk.AutoCAD.AutoCAD_2010_plug_in1
{

    public class MyPlugin : IExtensionApplication
    {

        private static string startup = @"C:\Program Files\Autodesk\ACADM 2010\Support\LexStartup.dll";
        private static string GetThangs = @"C:\Program Files\Autodesk\ACADM 2010\Support\GetThangs10.dll";

        void IExtensionApplication.Initialize()
        {
            string Keypath = @"Software\Autodesk\AutoCAD\R18.0\ACAD-8005:409\Applications\LexStartup";
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            RegistryKey key = Registry.CurrentUser;
            key = key.OpenSubKey(Keypath,true);
            if (key == null)
            {
                key = Registry.CurrentUser;
                key = key.CreateSubKey(Keypath);
                key.SetValue("DESCRIPTION", (string)"LexStartup.dll autoload", RegistryValueKind.String);
                key.SetValue("LOADCTRLS",2,RegistryValueKind.DWord);
                key.SetValue("MANAGED", 1, RegistryValueKind.DWord);
                key.SetValue("LOADER", startup, RegistryValueKind.String);
            }
            key.Close();

            Keypath = @"Software\Autodesk\AutoCAD\R18.0\ACAD-8005:409\Applications\LexStartup2";
            key = Registry.CurrentUser;
            key = key.OpenSubKey(Keypath, true);
           
                if (key == null)
                {
                    key = Registry.CurrentUser;
                    key = key.CreateSubKey(Keypath);
                    key.SetValue("DESCRIPTION", (string)"GetThangs10.dll autoload", RegistryValueKind.String);
                    key.SetValue("LOADCTRLS", 2, RegistryValueKind.DWord);
                    key.SetValue("MANAGED", 1, RegistryValueKind.DWord);
                    key.SetValue("LOADER", GetThangs, RegistryValueKind.String);
                }
                key.Close();
           
            CopyFile();
            doc.Editor.WriteMessage("\nC# loading");

        } //End Initialize



        void IExtensionApplication.Terminate()
        {
            // Do plug-in application clean up here
        }

       

        public static void CopyFile()
        {
            Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
            string sMainfile=@"I:\0001 DesignPro\Menu\lexVba\C#\GetThangs10.dll";
           

            if (!File.Exists(GetThangs))
            {
                File.Copy(sMainfile, GetThangs);
                ed.WriteMessage("\nCopying file.");
                return;
            }

            FileInfo fileInfo = new FileInfo(sMainfile);
            DateTime date = fileInfo.LastWriteTime;
            DateTime dateCopy = File.GetLastWriteTime(GetThangs);
           
            if (fileInfo.Exists)
            {               
                if (((double)(date - dateCopy).Seconds) > 15.0)
                {
                    ed.WriteMessage("\nUpdating file.");
                    File.Copy(sMainfile, GetThangs, true);
                }
            }
        } //End CopyFile


    }//End MyPlugin

}