pixel8er Posted September 1, 2016 Posted September 1, 2016 Hi all I'm trying to use lisp to create a new directory in my homedrive - but it's not working. The routine is this one by the awesome Lee Mac. So the code to call the function is (LM:createdirectory "%HOMEDRIVE%\\AutoCAD2013\\Support") ...which doesn't work, and returns nil If I use this code (LM:createdirectory "C:\\AutoCAD2013\\Support") ...it works. I have full control permissions on the home drive. Is there something else about the home drive that is stopping the creation of the folders? Thanks Paul Quote
BIGAL Posted September 1, 2016 Posted September 1, 2016 What does this return (getenv "Homedrive") for me "c:" Quote
pixel8er Posted September 1, 2016 Author Posted September 1, 2016 What does this return (getenv "Homedrive") for me "c:" I get "G:" which is where I can see my home drive so assume correct? Quote
BIGAL Posted September 1, 2016 Posted September 1, 2016 (edited) Sometimes networks need the \\baracudda\users rather than G: Play with (vl-mkdir dir) try different options for dir Other way is old fashioned DOS using a bat file called from Autocad. G: CD..... MD.... etc This worked for me (vl-mkdir "P:\\temp\\alan") so try (vl-mkdir (strcat (getenv "homedrive") "\\temp\\alan")) Edited September 1, 2016 by BIGAL Quote
pixel8er Posted September 1, 2016 Author Posted September 1, 2016 I got an error message ; error: bad argument type: stringp nil Quote
BIGAL Posted September 1, 2016 Posted September 1, 2016 Fixed when posting "\\mydrive is converted to a URL address did not notice removes quotes ", edited code now working needs in quotes "c:\\Temp\\Alan" etc Quote
Lee Mac Posted September 1, 2016 Posted September 1, 2016 You will first need to convert the environment variable %HOMEDRIVE% to a UNC path, e.g.: ;; Expand Environment String - Lee Mac (defun LM:expenvstr ( str / res wsh ) (if (setq wsh (vlax-create-object "wscript.shell")) (progn (setq res (vl-catch-all-apply 'vlax-invoke (list wsh 'expandenvironmentstrings str))) (vlax-release-object wsh) (if (null (vl-catch-all-error-p res)) res ) ) ) ) (LM:createdirectory (LM:expenvstr "%HOMEDRIVE%\\AutoCAD2013\\Support")) Or using: (LM:createdirectory (strcat (getenv "HOMEDRIVE") "\\AutoCAD2013\\Support")) Quote
pixel8er Posted September 2, 2016 Author Posted September 2, 2016 Fixed when posting "\\mydrive is converted to a URL address did not notice removes quotes ", edited code now working needs in quotes "c:\\Temp\\Alan" etc Thanks Alan. I saw that and typed it in manually - still didn't work. I have a feeling there is something a bit strange with the permissions. Quote
pixel8er Posted September 2, 2016 Author Posted September 2, 2016 You will first need to convert the environment variable Thanks so much Lee! That worked perfectly. Much appreciated Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.