Author Topic: Need a CrashACAD program/technique  (Read 6545 times)

0 Members and 2 Guests are viewing this topic.

Drafter X

  • Swamp Rat
  • Posts: 578
Re: Need a CrashACAD program/technique
« Reply #15 on: September 21, 2012, 08:16:01 AM »
make a series of offset ellipses cut by straight lines, hatch it associatively and then stretch the ellipses?
I always do that with beta versions of autocad and seems to give me a decent idea of how stable that iteration is.  :evil:
CadJockey Militia Commander

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Need a CrashACAD program/technique
« Reply #16 on: November 28, 2014, 03:43:33 PM »
I had need to use this tool today and found to my dismay it wouldn't run under 64 bit Windows (7 Pro), so I quickly bashed out an alternate:

Code: [Select]
(defun _KillProcess ( process_name / @try shell filename handle )

    ;;  Written by Michael Puckett, 2014

    (defun @try ( try_statement ) ;; dumbed down version of mp.lsp: _Try           
        (vl-catch-all-apply
            (function
                (lambda ( )
                    (eval try_statement)
                )
            )
        )
    )

    (vl-load-com)

    (setq
        shell    (vlax-create-object "Shell.Application")
        filename (vl-filename-mktemp "kill.vbs")
        handle   (open filename "w")
    )

    (foreach x
        (list
            (strcat
                "Set wmiService = GetObject(\"winmgmts:"
                "{impersonationLevel=impersonate}!\\\\"
                ".\\root\\cimv2\")"
            )
            (strcat
                "Set processList = wmiService.ExecQuery"
                "(\"Select * from Win32_Process Where Name = '"
                process_name
                "'\")"
            )
            "For Each process in processList"
            "    process.Terminate()"
            "Next"
            "Set processList = Nothing"
            "Set wmiService = Nothing"
        )
        (princ (strcat x "\n") handle)
    )

    (close handle)
   
    (@try '(vlax-invoke shell 'ShellExecute "cscript.exe" filename "" "runas" 0))
   
    (@try '(vlax-release-object shell))

    ;;  It's tempting to delete the temp vbs file we created above
    ;;  but due to asynchronous execution of the shell execution
    ;;  relative to the execution of this lisp function it tends to
    ;;  terminate the shell execution prematurely (subtitle: we finish
    ;;  before it does), so we'll just have to live with the litter
    ;;  we've generated.
   
    (princ)

)

Example:

(_KillProcess "notepad.exe")

FWIW ... Cheers.
« Last Edit: November 30, 2014, 04:08:22 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst