Jump to content
Sign in to follow this  
tazdev

What am I doing wrong?

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.


It's my job to comfort the disturbed and to disturb the comfortable.
My Projects: Profiler, MakeSFX, UserInfo, Simple Robocopy Progressbar

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...