Lisp File to check Service Pack Version

Lisp File to check Service Pack Version

Kyle-Evans
Collaborator Collaborator
1,756 Views
9 Replies
Message 1 of 10

Lisp File to check Service Pack Version

Kyle-Evans
Collaborator
Collaborator

Hello Everyone!

 

A little background... I teach Civil 3D at University, and the students have their own program provided computers. It is up to them to install their own service packs, but no matter how often you tell them too, the majority do not. Last year using 2019 was a nightmare because of this problem.

 

I have a server lisp file to set up various things, is there a way I can build into that to check the service pack version and if it is not up to date, annoy them with alerts until they update and it goes away?

 

I know there is a way to check the version you are using, however it checks the year, not the service packs.

 

Thanks in Advance!

0 Likes
Accepted solutions (2)
1,757 Views
9 Replies
Replies (9)
Message 2 of 10

ronjonp
Mentor
Mentor

Not sure how to check for the service pack number off the top of my head, but you can update those computers silently via the command line?

I'd imagine the updater has a quick check within it to see if its applicable.

 

This might help out if you know what return you're looking for:

(getvar '_vernum)
0 Likes
Message 3 of 10

Kyle-Evans
Collaborator
Collaborator
Awesome, I can make that work with my lisp file I think!

Now a question, if I build this into my lisp, and have it pointing to a
specific spot and a user opens Civil 3D to install it, will it try to
install again the next time they open up? I would want to dump all the
updates in one spot and just build a master lisp file to make sure
everything is installed as it comes out.

Thanks!
0 Likes
Message 4 of 10

ronjonp
Mentor
Mentor

Assuming you're the network admin, I'd add the silent update to the startup script when the computer logs in. You won't be able to update AutoCAD while it's open.

0 Likes
Message 5 of 10

Kyle-Evans
Collaborator
Collaborator

Just an instructor, not a network admin. And our IT department around here is so helpful that this may just be a pipe dream. I am going to assume that there is no way I can take this into my own hands. 

0 Likes
Message 6 of 10

ronjonp
Mentor
Mentor
Accepted solution

I guess you will need to just bug your users to update. I'm on 2020 and don't have any service packs installed, the code below returns "0" .. perhaps it will help with your check 🙂

(defun _getservicepack (/ i r)
  ;; RJP » 2019-06-11
  (setq r (strcat "HKEY_LOCAL_MACHINE\\" (vlax-machine-product-key)))
  (and (setq i (vl-string-search ":" r)) (setq r (substr r 1 i)))
  (if (setq i (car (vl-registry-descendents (setq r (strcat r "\\ProductInfo\\")))))
    (vl-registry-read (strcat r i) "SPNum")
  )
)
(_getservicepack)
0 Likes
Message 7 of 10

Kyle-Evans
Collaborator
Collaborator

It returns a 2 when I run it, I am on 2019.2.

 

I will have to find someone with 2019.1 and try it

0 Likes
Message 8 of 10

ronjonp
Mentor
Mentor

@Kyle-Evans wrote:

It returns a 2 when I run it, I am on 2019.2.

 

I will have to find someone with 2019.1 and try it


Looks promising! 🙂

0 Likes
Message 9 of 10

Kyle-Evans
Collaborator
Collaborator

Yes, and if it returns anything other than a 2 for example, I can have it prompt the students to update through the Autodesk Desktop App! 

 

Annoy them with prompts so they actually do it.... 

0 Likes
Message 10 of 10

ronjonp
Mentor
Mentor
Accepted solution

Quick update .. I tested on version AutoCAD 2017.1.2 and the code returns "4" which is how many updates there have been. There is a ProductName under the r\\Service Packs\\ProductName key .. but it's not as precise as the 'SPNum"

image.png

Or to return the latest service pack as something relateable:

(defun _getservicepack (/ i r)
  ;; RJP » 2019-06-11
  (setq r (strcat "HKEY_LOCAL_MACHINE\\" (vlax-machine-product-key)))
  (and (setq i (vl-string-search ":" r)) (setq r (substr r 1 i)))
  (car (vl-registry-descendents (setq r (strcat r "\\ProductInfo\\"))))
)
(_getservicepack)
;; Returns "AutoCAD 2017.1.2 Update" 
;; Example
(if (wcmatch (_getservicepack) "*2017.1.2*")
  (print "Up to date...")
  (alert "Update your ****e yo!")
)

Enjoy!

0 Likes