Jump to content

Recommended Posts

Posted (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 by tazdev
Posted

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)

Posted

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

:lmao:

Posted

;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')

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
×
×
  • Create New...