Author Topic: Loading routine in Startup suite  (Read 5786 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Loading routine in Startup suite
« on: August 15, 2012, 10:04:23 AM »
Hi all,..

I've made this to load a routine in a startup suite..
but,..I would like to know if there is some easier way...
thanks.

Code: [Select]
;;Adding application in Startup Suite
;;Andrea Andreetti 2012-08-15

(defun PUT_PROFILES_APPLICATIONS (appname / acadver cprofile NumStrUp atoi# keypath keyloc)

  (setq acadver (strcat "R" (substr (getvar 'acadver) 1 (1- (vl-string-search " " (getvar 'acadver))))))
  (setq cprofile (getvar 'cprofile))

  (defun GET_prodKey (/ prodKey val)
    (setq prodKey (vlax-product-key))
    (while (setq val (vl-string-search "\\" prodKey))
      (setq prodKey (substr prodKey (+ val 2)))
    )
  )

  (if (not
(setq NumStrUp (vl-registry-read
(strcat "HKEY_CURRENT_USER\\Software\\AutoDESK\\AutoCAD\\"
acadver
"\\"
(GET_prodKey)
"\\Profiles\\"
cprofile
"\\Dialogs\\Appload\\Startup"
)
"NumStartup"
       )
)
      )
    (setq NumStrUp "0")
  )

  (setq atoi# (1+ (read NumStrUp)))
  (vl-registry-write
    (strcat "HKEY_CURRENT_USER\\Software\\AutoDESK\\AutoCAD\\"
    acadver
    "\\"
    (GET_prodKey)
    "\\Profiles\\"
    cprofile
    "\\Dialogs\\Appload\\Startup"
    )
    (strcat (itoa atoi#) "Startup")
    appname
  )
  (vl-registry-write
    (strcat "HKEY_CURRENT_USER\\Software\\AutoDESK\\AutoCAD\\"
    acadver
    "\\"
    (GET_prodKey)
    "\\Profiles\\"
    cprofile
    "\\Dialogs\\Appload\\Startup"
    )
    "NumStartup"
    (itoa atoi#)
  )

  (foreach rd (vl-registry-descendents "HKEY_USERS")
    (if (vl-registry-read
  (setq keypath
(strcat "HKEY_USERS\\"
rd
"\\Software\\AutoDESK\\AutoCAD\\"
acadver
"\\"
(GET_prodKey)
"\\Profiles\\"
cprofile
"\\Dialogs\\Appload\\Startup\\"
)
  )
  "NumStartup"
)
      (setq keyloc keypath)
    )
  )
  (if keyloc
    (progn
      (vl-registry-write keyloc "NumStartup" (itoa atoi#))
      (vl-registry-write keyloc (strcat (itoa atoi#) "Startup") appname)
    )
  )
  (princ)
)
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Loading routine in Startup suite
« Reply #1 on: August 15, 2012, 10:11:06 AM »
I would like to know if there is some easier way...

Append a load expression to the ACADDOC.lsp?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Loading routine in Startup suite
« Reply #2 on: August 15, 2012, 10:11:45 AM »
I would like to know if there is some easier way...

Append a load expression to the ACADDOC.lsp?

X2   Or if you're loading a menu, put it in your mnl file.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Loading routine in Startup suite
« Reply #3 on: August 15, 2012, 10:21:40 AM »
Append a load expression to the ACADDOC.lsp?
X3

Or if you're loading a menu, put it in your mnl file.
X2  :D

Personally, I stay the heck away from StratupSuite ... been burned too often by it. Not to mention it's just so difficult to setup across several PC's! I'm guessing your code is attempting to make this process easier.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Loading routine in Startup suite
« Reply #4 on: August 15, 2012, 10:26:29 AM »
BTW, you might cut down on some of your code using the vlax-product-key function instead. Though I think I've seen somewhere that it's being deprecated in 2013 - split into 2 other versions.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Loading routine in Startup suite
« Reply #5 on: August 15, 2012, 10:44:28 AM »
ok than you Guys...

I've created this beaucause I can't use acaddoc.lsp or acad.lsp for some clients specific custumisation requirement.
so,....-3 for me. :pissed:

thanks for the advise Irneb, i'll make more tests.
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Loading routine in Startup suite
« Reply #6 on: August 15, 2012, 09:14:28 PM »
ok than you Guys...

I've created this beaucause I can't use acaddoc.lsp or acad.lsp for some clients specific custumisation requirement.
so,....-3 for me. :pissed:

thanks for the advise Irneb, i'll make more tests.

In that case, provide a simple menu and a simarly named .MNL
the client loads the menu ( mnu/cuix) and thew MNL will run automatically.
AutoCAD will remember and reload the menu at each start.
Simple !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Loading routine in Startup suite
« Reply #7 on: August 15, 2012, 10:02:26 PM »
ok than you Guys...

I've created this beaucause I can't use acaddoc.lsp or acad.lsp for some clients specific custumisation requirement.
so,....-3 for me. :pissed:

thanks for the advise Irneb, i'll make more tests.

In that case, provide a simple menu and a simarly named .MNL
the client loads the menu ( mnu/cuix) and thew MNL will run automatically.
AutoCAD will remember and reload the menu at each start.
Simple !

well not simple at all,
some of our Client do not have a menu but a program made with VB who change settings during the work process
one of these have specifics needs, Some others have huge menus and toolbars who they unload and reload depending the departement dicscipline.
some have mnl, some not.

even more,...I've added this options into my old tool who make backup on a LAN server by autocad version and export of all profiles ARG, variables settings, pgp, cuix, cui, mnl, mnu, custum settings and now automate the startup suite depending the department of each CAD user.

This program save lot of headache and time work for our IT when need to change users PC or make a new one based on a workmate for a new employee, in this fact, all they have to do is to start my program and make a restore.
my rogram retreive all CAD users settings, menus, tools, configuration, programs etc...... on 1 click !
then, give the PC to the user ready to use.

My program can also allow to switch user, I mean....If the user need to work in another department with their own menu and programs...
the IT or user just need to restore a config from any CAD user of any specific department.

We are over 600 CAD user here working on diffrent discipline with diffrent standards and custom client programs.
many employee work for diffrent discipline.

so you can imagine.
Keep smile...

BlackBox

  • King Gator
  • Posts: 3770
Re: Loading routine in Startup suite
« Reply #8 on: August 16, 2012, 09:16:56 AM »
We build into our profile (for each version) custom folders stored on the user's personal network space (that only they can read/write) using their LOGINNAME, so that no matter what computer they log into, _their_ customized settings are loaded by default (i.e., Main CUIx, PGP, etc.).

This makes it easy for any user to log into the laptop in a conference room for meetings, etc. and still have their settings, menus, keyboard shortcuts, etc. available immediately.

We store all Enterprise customizations on the network where user's are not allowed to write, but can also read from any work station. I use offline files for Laptop users (like myself).
"How we think determines what we do, and what we do determines what we get."

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Loading routine in Startup suite
« Reply #9 on: August 16, 2012, 10:27:54 AM »
Well, if you really want to add your lisp file to the startup suite, and ensure it's available to all users on all versions of acad installed. Perhaps something like this:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun TestStartup (reg-key file / num found)
  3.   (if (setq num (vl-registry-read reg-key "NumStartup"))
  4.     (progn (setq num (1+ (itoa num)) file (strcase file))
  5.       (while (and (not found) (> (setq num (1- num))))
  6.         (setq found (eq file (strcase (vl-registry-read reg-key (strcat (itoa num) "Startup"))))))
  7.       found)))
  8.  
  9. (defun AddStartup (reg-key file / num)
  10.   (if (setq num (vl-registry-read reg-key "NumStartup"))
  11.     (vl-registry-write reg-key (strcat (itoa (1+ (atoi num))) "Startup") file)))
  12.  
  13. (defun AddAllStartup (file / key)
  14.   (foreach root (cons "HKEY_CURRENT_USER" (mapcar '(lambda (usr) (strcat "HKEY_USERS\\" usr)) (vl-registry-descendents "HKEY_USERS")))
  15.     (foreach version (vl-registry-descendents (strcat root "\\Software\\Autodesk\\AutoCAD"))
  16.       (foreach product (vl-registry-descendents (strcat root "\\Software\\Autodesk\\AutoCAD\\" version))
  17.         (foreach profile (vl-registry-descendents (strcat root "\\Software\\Autodesk\\AutoCAD\\" version "\\Profiles"))
  18.           (if (not (TestStartup (setq key (strcat root "\\Software\\Autodesk\\AutoCAD\\" version "\\Profiles\\" profile "\\Dialogs\\Appload\\Startup")) file))
  19.             (AddStartup key file)))))))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Loading routine in Startup suite
« Reply #10 on: March 07, 2016, 09:47:51 AM »
We build into our profile (for each version) custom folders stored on the user's personal network space (that only they can read/write) using their LOGINNAME, so that no matter what computer they log into, _their_ customized settings are loaded by default (i.e., Main CUIx, PGP, etc.).

This makes it easy for any user to log into the laptop in a conference room for meetings, etc. and still have their settings, menus, keyboard shortcuts, etc. available immediately.

We store all Enterprise customizations on the network where user's are not allowed to write, but can also read from any work station. I use offline files for Laptop users (like myself).

Could you please Give more explain how to do that?

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Loading routine in Startup suite
« Reply #11 on: March 07, 2016, 09:58:19 AM »
Quote from: HasanCAD
Could you please Give more explain how to do that?

I'm not speaking for @BlackBox, but in my case, we detect the username at startup in Acad.lsp, and load the appropriate items for that user.
Each user has a folder on the network and items in that folder are loaded based on the loginname.


dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Loading routine in Startup suite
« Reply #12 on: March 07, 2016, 12:36:41 PM »
We do it slightly differently, with management done on the IT side.  Every user gets a unique network "G:" drive.  I keep our Main CUIx, PGP, etc. under standard folder paths in that drive.  So it doesn't matter if its "User A" or "User Z", they both have G:\AutoCAD Settings\blah blah\..., and both of them are unique to that user.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Loading routine in Startup suite
« Reply #13 on: March 07, 2016, 12:41:20 PM »
Quote from: dgorsman
We do it slightly differently, with management done on the IT side.  Every user gets a unique network "G:" drive.  I keep our Main CUIx, PGP, etc. under standard folder paths in that drive.  So it doesn't matter if its "User A" or "User Z", they both have G:\AutoCAD Settings\blah blah\..., and both of them are unique to that user.

I probably wasn't clear on this point. We do that same thing also.
Everyone gets a standard setup (menus, paths, printers, lisp files, etc.), but after that loads it checks for any user specific items to load also.


BlackBox

  • King Gator
  • Posts: 3770
Re: Loading routine in Startup suite
« Reply #14 on: March 07, 2016, 04:43:55 PM »
We build into our profile (for each version) custom folders stored on the user's personal network space (that only they can read/write) using their LOGINNAME, so that no matter what computer they log into, _their_ customized settings are loaded by default (i.e., Main CUIx, PGP, etc.).

This makes it easy for any user to log into the laptop in a conference room for meetings, etc. and still have their settings, menus, keyboard shortcuts, etc. available immediately.

We store all Enterprise customizations on the network where user's are not allowed to write, but can also read from any work station. I use offline files for Laptop users (like myself).

Could you please Give more explain how to do that?

Building on @rkmcswain's & @dgorsman's apt comments....

This is initially setup on the IT side, where the user's Active Directory account is assigned a 'home folder' which resides on the network, and is assigned a drive letter, for which only that user (and Admins) have write-access to.

From Active Directory, this is done by opening the user's Properties, Profile tab, Home folder section (at bottom), check the 'Connect' radio button, specify a drive letter from the dropdown, and then paste the UNC path in the textbox. For these changes to take affect, have the user log off, and back onto their workstation.

With that in place - this 'personal network space' - now I begin to create version-specific folders for each deployment (i.e., I:\CAD\2014, I:\CAD\2015, I:\CAD\2016, I:\CAD\Common, etc.), usually created via .BAT as part of our initial deployment, or updates, but it can be done in several different ways (i.e., PowerShell, etc.).

The ..\Common\ folder might store anything that should be available to all versions, such as Apps/plugins, Fonts, Linetypes, LISP, Hatch Patters, Scripts, or Tool Palettes, etc.

The version-specific folders, might hold the user's custom CUI, LISP, Scripts, Tool Palettes, etc., so that they can customize each as they wish, without affecting the Enterprise files (stored on the network where user does not have write-access).

All of these file paths are mapped into that version's SFSP, etc. so that the user just launches AutoCAD, and has all of their (as well as the Enterprise's) customizations on first run, or after an update.


The point is, that by having your script use the user's personal network space location, these user-specific files, folders, and settings, are always stored in a location that is both consistent for each user, and available to each user no matter what machine they log into.

As example:

You have a client meeting in the conference room; you just log into the conference room laptop (provided it too, has a valid AutoCAD license, etc.).

A workstation crashes, and requires IT support? Simply log into any other workstation, provided you have an available workstation as CYA, and a valid license, etc.


This scenario also allows for all user-specific settings to be backed up, so if they accidentally delete something critical, CUI becomes corrupt, etc. it's usually a simple task to restore from last good backup copy, regardless of using Windows' File History availability.

HTH
"How we think determines what we do, and what we do determines what we get."