tazdev Posted January 25, 2005 Share Posted January 25, 2005 (edited) I totally do not understand how to use @comspec. I am trying to get a listing of the My Documents directory and have that placed into c:\temp.txt In dos I would type cd\documents and settings\myprofile\my documents dir *.* /s /b>c:\temp.txt That would make a temp file with the files listed. Why doesn't the below work? All I get is an empty file. $filedir = (@MyDocumentsDir & "\*.* /s /b>c:\temp.txt") Runwait(@comspec & " /c " & "dir " & $filedir) Edited January 25, 2005 by tazdev Link to comment Share on other sites More sharing options...
Marc Posted January 25, 2005 Share Posted January 25, 2005 Try this one: $filedir = ('"' & @MyDocumentsDir & '"' & "\*.* /s /b>c:\temp.txt") Runwait(@comspec & " /c " & "dir " & $filedir) Good old DOS Box does not like long path names, especially ones containing spaces... to avoid this problem, you should embrace the path with " and you're done. Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
MHz Posted January 25, 2005 Share Posted January 25, 2005 $filedir = '"' & @MyDocumentsDir & '\*.*" /s /b>c:\temp.txt' Runwait(@comspec & " /c " & "dir " & $filedir) Notice the use of single quotes, as to double quotes. Your Dos equivalent requires quotes also, when spaces are within the address. Link to comment Share on other sites More sharing options...
tazdev Posted January 25, 2005 Author Share Posted January 25, 2005 I will be the first to say it DUH Thanks Link to comment Share on other sites More sharing options...
SlimShady Posted January 25, 2005 Share Posted January 25, 2005 ;Example 1 $filedir = @MyDocumentsDir RunWait(@ComSpec & " /c DIR *.* /S /B>c:\temp.txt", $filedir) ;Example 2 RunWait(@ComSpec & " /c DIR *.* /S /B>c:\temp.txt", @MyDocumentsDir) ;Example 3 RunWait(@ComSpec & ' /c DIR "' & @MyDocumentsDir & '" /S /B>c:\temp.txt') 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