Mussie Posted August 17, 2006 Share Posted August 17, 2006 Hey allI am a new user to Autoit, I have used it in the past about two years ago but it was only for a short time.I have started making a GUI, its mainly for launching document templates and remote connections to client machines....I found that I was having a lot of trouble with spaces in long filenames on network drives and after a number of hours of messing about (which included 20 - 30 smokes and even more curse words ), I found a solution that appears to work .Example (These are arbitrary paths only)Problem Path: L:\Unit Folder\Unit Development\Template.dotSolution : L:\unitfo~1\Unitde~1\Template.dotI would like to know if my approach is going to cause unforseen problems. Also can I have your opinions on the best tutorial to read, I am quite competent (Not an Expert) with VBA, Dos Scripting and a little C++. I have always found it difficult retain information by studying and have learnt most of what I know by setting myself a project and figuring out how to do it. (yeah I am one of those ppl who reads the manual only after the IKEA bed ends up looking like a cupboard )So thanks in advanceLater Mussie Link to comment Share on other sites More sharing options...
MHz Posted August 17, 2006 Share Posted August 17, 2006 Example (These are arbitrary paths only) Problem Path: L:\Unit Folder\Unit Development\Template.dot Solution : L:\unitfo~1\Unitde~1\Template.dot I would like to know if my approach is going to cause unforseen problems. Yes to problems, as you have dreamed up a 8.3 fullpath. Try this test ; create folders DirCreate(@ScriptDir & '\Unit Folder test1') DirCreate(@ScriptDir & '\Unit Folder test2') ; get 8.3 fullpath $result = FileGetShortName(@ScriptDir & '\Unit Folder test2') MsgBox(0, '', $result) ; remove folders DirRemove(@ScriptDir & '\Unit Folder test1') DirRemove(@ScriptDir & '\Unit Folder test2') oÝ÷ Ù¬º[Hë[OvPÒí¿lÚ-Çí¨Ø^zw@³*.«ÞºÇä²g§¶*'yÛazwh¹¹^ªê-zȬ¶¬¢[Ô²)à)^ëRí5©Æ§¢Ø^®mÛºØ×Ú[-é⶷º¹ì¶ºYijØp'!r¥u·Æ¬µêèºÈºÈ§+pØZ)ízºkz׫) ¥ç+"³r"ëªê-zƬ²0·¥£¢ ^ªê-zÌ+j^uªèºwmçh¹¹^ªê-zÌ"W§i¹^¶¢æåz«¨µë-¡·«zÖ¢ç_¢¼¨º»¬y«¢+Ø)IÕ¸¡ ½µMÁµÀìÌäì½ÅÕ½Ðí0èÀäÈíU¹¥Ð½±ÈÀäÈíU¹¥ÐÙ±½Áµ¹ÐÀäÈíQµÁ±Ñ¹½ÐÅÕ½ÐìÌäì¤( Take care if you use the Start command with @ComSpec as the 1st set of double quotes can be used for the title, so would perhaps risk using FileGetShortName() for that. Link to comment Share on other sites More sharing options...
Mussie Posted August 17, 2006 Author Share Posted August 17, 2006 In relation to the test you suggested: My actual development directory contained two folders with similar names so to ensure I was accessing the correct folder I used the dos command dir /x to display the correct 8.3 filenames. But I think I can see where your coming from, i.e. what happens if I have two folders with similar names and one is deleted at a later date...In relation to Using Quotes I was getting the error you mentioned where my path was being used as the title for the DOS window and I also kept getting the cannot execute external program error. I have copied your line and used my path and of course its working fine. I must have used incorrect syntax somewhere ..... ? Out of curiosity When you said but if it fails, then it returns the full path which could be disastrous if using it with an interpreter like @ComSpec. could you give me an example of the sort of result you mean. Thanks for the response MHZ Link to comment Share on other sites More sharing options...
MHz Posted August 17, 2006 Share Posted August 17, 2006 (edited) Here is one attempt at making it fail on purpose. I'm using a non existant path to make it fail easy. ; create folders DirCreate(@ScriptDir & '\Unit Folder test1') DirCreate(@ScriptDir & '\Unit Folder test2') ; get 8.3 fullpath $result = FileGetShortName(@ScriptDir & '\Unit Folder test3') MsgBox(0, '', $result) MsgBox(0, 'Test', 'Using quotes') RunWait(@ComSpec & ' /c start /w "' & $result & '"') MsgBox(0, 'Test', 'Not using quotes') RunWait(@ComSpec & ' /c start /w ' & $result) ; remove folders DirRemove(@ScriptDir & '\Unit Folder test1') DirRemove(@ScriptDir & '\Unit Folder test2') Edit: Without quotes you get the nasty popup from windows. Edit: Hmm...that is not right after all as the 1st uses $result as the title Edited August 17, 2006 by MHz Link to comment Share on other sites More sharing options...
MHz Posted August 17, 2006 Share Posted August 17, 2006 This shows an issue as explorer does not like 8.3 paths (and I have noticed before that some other programs dislike it also). DirCreate(@ScriptDir & '\Unit Folder test1') DirCreate(@ScriptDir & '\Unit Folder test2') ; Fullpath quoted MsgBox(0, '', '"' & @ScriptDir & '\Unit Folder test2' & '"', 3) RunWait(@ComSpec & ' /c explorer "' & @ScriptDir & '\Unit Folder test2' & '"') Opt('WinTitleMatchMode', 2) WinWait('Unit Folder test2') Sleep(2000) WinClose('Unit Folder test2') ; 8.3 fullpath $result = FileGetShortName(@ScriptDir & '\Unit Folder test2') MsgBox(0, '', $result, 3) RunWait(@ComSpec & ' /c explorer ' & $result) DirRemove(@ScriptDir & '\Unit Folder test1') DirRemove(@ScriptDir & '\Unit Folder test2') Link to comment Share on other sites More sharing options...
Mussie Posted August 17, 2006 Author Share Posted August 17, 2006 The script 1- creates two folder 2- displays a msgbox with the file path to unit folder 2 3- opens an explorer window to unit folder 2 4- closes the above window 5- displays a msgbox with the 8.3 file path to unit folder 2 6- opens an explorer window to unit folder 2 using the 8.3 path 7- deletes both folders Sorry MHz but unless I am missing somthing it all appears to run correctly, What am i missing ? Link to comment Share on other sites More sharing options...
MHz Posted August 17, 2006 Share Posted August 17, 2006 Sorry MHz but unless I am missing somthing it all appears to run correctly, What am i missing ?The fullpath works while 8.3 fails here on XP SP2.---------------------------Windows Explorer---------------------------C:\Unit Folder test2 refers to a location that is unavailable. It could be on a hard drive on this computer, or on a network. Check to make sure that the disk is properly inserted, or that you are connected to the Internet or your network, and then try again. If it still cannot be located, the information might have been moved to a different location.---------------------------OK --------------------------- Link to comment Share on other sites More sharing options...
Mussie Posted August 17, 2006 Author Share Posted August 17, 2006 The fullpath works while 8.3 fails here on XP SP2. Ahh Ok I am on SP-1 here that would explain it... OS Name Microsoft Windows XP Professional Version 5.1.2600 Service Pack 1 Build 2600 OS Manufacturer Microsoft Corporation Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now