sulfurious Posted August 14, 2006 Share Posted August 14, 2006 Greets. Briefly, can use this np. RunWait(@Comspec & " /c " & "some path\some.exe" etc etc) Now, can use this np. as long as from root or no white space (ie. "Program Files") $x1 = $CmdLine[1] RunWait(@ComSpec & " /c " & "dir /s /b /ad " & $x1 & ">" & $x1 & "\dirs.txt") Problem exists with a path needed to be in quotes. I have flopped the ' and " around in every combo I could think of. Seems something trivial similar to SQL syntax. I also tried concating commands together like you can do from cmd prompt (ie. "command&&command2"). I also used variable to stop the concating in the @comspec line. Did not work either. Should mention that the $CmdLine comes from a right click context. Just passing the directory path. As you can tell, piping out the dir structure to txt file. Nothing complicated. Or so I thought. Anyone got any ideas on what I am missing? I have wasted too much time on this already. Conversely, is there a method to set the directory before calling @comspec so it is already in my passed $CmdLine path? Any help appreciated. Sul Link to comment Share on other sites More sharing options...
Knight Posted August 14, 2006 Share Posted August 14, 2006 FileGetShortName($FilePath) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 14, 2006 Moderators Share Posted August 14, 2006 (edited) Does this work?$x1 = $CmdLine[1] RunWait(@ComSpec & ' /c dir /s /b /ad "' & $x1 & '" > "' & $x1 & '\dirs.txt"')If the paths have spaces in them, they'll fail without double quotes or even using FileGetShortName(). Edited August 14, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
sulfurious Posted August 14, 2006 Author Share Posted August 14, 2006 Fast responses. Actually, both methods work at outputting. The FileGet method eliminates the need for manipulating the quotes around. The drawback to that method is that unless I use a switch for the dir command, the output in xp is long name. For 8.3 platforms I think it would be best method as the piped txt file would also be 8.3. But I need to see the long name format in the $x1 variable because that is what the txt will have. And it is also used in some [section] information, so long names would be beneficial. So, I did exactly as you did with the quote manipulation. Seems that Scite decided to cease and desist running the script from within itself. As I took more and more of the code out, and adding message boxes, nothing popped up. When I context menu the script to run it, it works. I have no idea what I did to get Scite to not run it, but I did it. Also, it helps to add in the registry key "%1" instead of %1. Heh heh. Thanks for the replies. Sul Link to comment Share on other sites More sharing options...
MHz Posted August 14, 2006 Share Posted August 14, 2006 (edited) Conversely, is there a method to set the directory before calling @comspec so it is already in my passed $CmdLine path?Since the commandline will be a directory path, then using fullpath after using FileChangeDir() with Comspec should not be neccessary. That means no quotes or FileGetShortName() needed. If FileChangeDir($CMDLINE[1]) Then Edit: Also you could have just used the commandline parameter as the working dir parameter in the Run() function. Ofcourse you may need quotes if the filename itself has spaces. Edited August 14, 2006 by MHz Link to comment Share on other sites More sharing options...
sulfurious Posted August 14, 2006 Author Share Posted August 14, 2006 So, if I get the drift here, you are saying I could have set @WorkingDir from the CommandLine parameter (passed from the context call), which would set the path that @Comspec would have opened by default? Sul Link to comment Share on other sites More sharing options...
MHz Posted August 14, 2006 Share Posted August 14, 2006 (edited) Yes Edit: An example of easy use $x1 = @UserProfileDir If FileChangeDir($x1) Then $pid = Run(@ComSpec & ' /c dir /s/b/a:d', '', @SW_HIDE, 2) $data = '' While 1 $data &= StdoutRead($pid) If @error Then ExitLoop WEnd MsgBox(0, '', $data) EndIf Edited August 14, 2006 by MHz Link to comment Share on other sites More sharing options...
sulfurious Posted August 14, 2006 Author Share Posted August 14, 2006 Cool. Thx for the tips. Now have a functional context menu item that when you choose a directory, creates an .inf file. Contains all files in [sourceDisksFiles], creates CopyFiles = statement and every [Copy] section, as well as [DestinationDirs],[strings] & [sourceDisks] sections. Then another context menu copies all said files into prep directory to be cabbed. Just need to use Reg2Inf now to convert the Reg to Inf entries and add cab name & any xtra files. As well as RegisterDll sections if needed. Thanks. Sul 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