Author Topic: Open Windows Explorer  (Read 3273 times)

0 Members and 1 Guest are viewing this topic.

KHoughton

  • Guest
Open Windows Explorer
« on: March 16, 2015, 11:15:46 AM »
I am using the code below to open Windows Explorer to a specific folder from within AutoCAD. It works on every computer except one. I do not get any errors to indicate that it is not working, it just doesn't open Explorer. Any ideas why it may not work on one computer?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:PPisofolder ()
  2. (startapp "explorer" (strcat "/n,/e," "S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols"))
  3. )

ChrisCarlson

  • Guest
Re: Open Windows Explorer
« Reply #1 on: March 16, 2015, 11:24:56 AM »
What happens when you enter this on the command line of the issue computer?

explorer.exe /n,/e,"S:\CAD_Standards\_SE_Custom\Piping\Symbols\Blocks\Iso_Symbols"

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Open Windows Explorer
« Reply #2 on: March 16, 2015, 11:26:32 AM »
Since it's a network folder have you tested to make sure the folder is accessible from that computer?
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ChrisCarlson

  • Guest
Re: Open Windows Explorer
« Reply #3 on: March 16, 2015, 11:31:01 AM »
If the folder isn't available, explorer "should" open to C:\Users\USERNAME\Documents

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Open Windows Explorer
« Reply #4 on: March 16, 2015, 11:48:31 AM »
You could try this alternative:

Code - Auto/Visual Lisp: [Select]
  1. (defun _opendirectory (path / sa)
  2.   (if (and (eq 'str (type path))
  3.            (findfile (vl-string-right-trim "\\" path))
  4.            (setq sa (vlax-create-object "Shell.Application"))
  5.       )
  6.     (progn (vlax-invoke sa 'explore path) (vlax-release-object sa))
  7.   )
  8.   (princ)
  9. )
  10.  
  11.  
  12. (_opendirectory "S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols")
  13.  
  14.  
  15. ;; Handy function
  16. (defun c:cd nil (_opendirectory (getvar 'dwgprefix)))
« Last Edit: March 16, 2015, 11:53:55 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

KHoughton

  • Guest
Re: Open Windows Explorer
« Reply #5 on: March 17, 2015, 01:08:06 PM »
What happens when you enter this on the command line of the issue computer?

explorer.exe /n,/e,"S:\CAD_Standards\_SE_Custom\Piping\Symbols\Blocks\Iso_Symbols"

When I enter this in the Windows command line on the issue computer I get an error message (attached image).

You could try this alternative:

Code - Auto/Visual Lisp: [Select]
  1. (defun _opendirectory (path / sa)
  2.   (if (and (eq 'str (type path))
  3.            (findfile (vl-string-right-trim "\\" path))
  4.            (setq sa (vlax-create-object "Shell.Application"))
  5.       )
  6.     (progn (vlax-invoke sa 'explore path) (vlax-release-object sa))
  7.   )
  8.   (princ)
  9. )
  10.  
  11.  
  12. (_opendirectory "S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols")
  13.  
  14.  
  15. ;; Handy function
  16. (defun c:cd nil (_opendirectory (getvar 'dwgprefix)))

This code works when I initially run it but after when I run it again it opens the folder where the current file is located. I need it to open the same folder ("S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols") all the time. I have limited knowledge of lisp so I was not able to manipulate it to accomplish what I need.

Thank you all for your help, it is greatly appreciated.

ChrisCarlson

  • Guest
Re: Open Windows Explorer
« Reply #6 on: March 17, 2015, 01:18:38 PM »
Couple things, known virus / malware free?

A modified routine from Ron would be this;

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun _opendirectory (path / sa)
  3.   (if (and (eq 'str (type path))
  4.            (findfile (vl-string-right-trim "\\" path))
  5.            (setq sa (vlax-create-object "Shell.Application"))
  6.       )
  7.     (progn (vlax-invoke sa 'explore path) (vlax-release-object sa))
  8.   )
  9.   (princ)
  10. )
  11.  
  12. (defun c:cd nil (_opendirectory "S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols"))
  13.  
  14.  

"cd" to run
« Last Edit: March 17, 2015, 01:22:09 PM by ChrisCarlson »

kraz

  • Guest
Re: Open Windows Explorer
« Reply #7 on: March 17, 2015, 08:10:42 PM »
what about this ..
Code - Auto/Visual Lisp: [Select]
  1. (defun openDir (gPath / )
  2.         (setq gPath (vl-string-subst "\\" "/" gPath))
  3.         (vl-cmdf ".shell" (strcat "explorer.exe " gPath))
  4. )
  5.  
« Last Edit: March 17, 2015, 08:32:34 PM by KRAZ »

ROBBO

  • Bull Frog
  • Posts: 217
Re: Open Windows Explorer
« Reply #8 on: March 18, 2015, 03:08:12 AM »
Code - Auto/Visual Lisp: [Select]
  1. (startapp "explorer.exe" "S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols")
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

KHoughton

  • Guest
Re: Open Windows Explorer
« Reply #9 on: March 18, 2015, 10:12:05 AM »
Couple things, known virus / malware free?

A modified routine from Ron would be this;

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun _opendirectory (path / sa)
  3.   (if (and (eq 'str (type path))
  4.            (findfile (vl-string-right-trim "\\" path))
  5.            (setq sa (vlax-create-object "Shell.Application"))
  6.       )
  7.     (progn (vlax-invoke sa 'explore path) (vlax-release-object sa))
  8.   )
  9.   (princ)
  10. )
  11.  
  12. (defun c:cd nil (_opendirectory "S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols"))
  13.  
  14.  

"cd" to run


This works perfect. Thank you all very much!!

ChrisCarlson

  • Guest
Re: Open Windows Explorer
« Reply #10 on: March 18, 2015, 10:59:04 AM »
Couple things, known virus / malware free?

A modified routine from Ron would be this;

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun _opendirectory (path / sa)
  3.   (if (and (eq 'str (type path))
  4.            (findfile (vl-string-right-trim "\\" path))
  5.            (setq sa (vlax-create-object "Shell.Application"))
  6.       )
  7.     (progn (vlax-invoke sa 'explore path) (vlax-release-object sa))
  8.   )
  9.   (princ)
  10. )
  11.  
  12. (defun c:cd nil (_opendirectory "S:\\CAD_Standards\\_SE_Custom\\Piping\\Symbols\\Blocks\\Iso_Symbols"))
  13.  
  14.  

"cd" to run


This works perfect. Thank you all very much!!

If you want any other folders to open add a line similar to this

Code - Auto/Visual Lisp: [Select]
  1. (defun c:cd1 nil (_opendirectory "Drive:\\Folder\\Folder"))
  2.  

77077

  • Guest
Re: Open Windows Explorer
« Reply #11 on: May 27, 2015, 08:51:30 PM »
@ronjonp  good function.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Open Windows Explorer
« Reply #12 on: May 28, 2015, 01:11:58 AM »
@ronjonp  good function.
Thanks  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC