Jump to content

@Comspec with dir command - stumped


Recommended Posts

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

  • Moderators

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 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

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

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

:whistle:

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 by MHz
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...