Sign in to follow this  
Followers 0
b1ff

Spaces in Environment Variables

7 posts in this topic

Hi everybody,

first of all: i'm new to this, so please be gentle :">

I'm trying to write a script that puts the content of "dir /b" to an array, but i can't figure out how exactly the syntax has to be when i'm using @Userprofiledir because it's got spaces whithin.

I'm doing this with a detour over a file that is then read into the array.

This is my code:

#include <file.au3>
#include <Array.au3>


RUNWAIT(@COMSPEC & " /k dir "& @userprofiledir &" > c:\temp\userprofiles.log")
DIM $userprofiles
_FileReadToArray("C:\temp\userprofiles.log",$userprofiles)
FILEDELETE("c:\temp\userprofiles.log")
_ArrayDisplay($userprofiles, "lala")
_ArrayPop($userprofiles)
_ArrayReverse($userprofiles)
_ArrayPop($userprofiles)
_ArrayReverse($userprofiles)

It keeps telling me that the file does not exist.

Thanks in advance,

b1ff

Share this post


Link to post
Share on other sites



If you use Beta version you can use _FileListToArray

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray(@userprofiledir)
If (Not IsArray($FileList)) and (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

If you use Beta version you can use _FileListToArray

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray(@userprofiledir)
If (Not IsArray($FileList)) and (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")
Great, thanks für the fast answer, I'll check that out.

But anyway, how would the syntax be?

Thanks,

b1ff

Share this post


Link to post
Share on other sites

RunWait(@COMSPEC & ' /k dir "' & @userprofiledir & '" > c:\temp\userprofiles.log')
Thx MHz, but this does not seem to work!

RunWait(@COMSPEC & ' /k dir "' & @userprofiledir & '" > c:\temp\userprofiles.log'

RunWait(@COMSPEC & ' /k dir "' & @userprofiledir & '^ ERROR

ERROR: Error parsing function call

:)

Share this post


Link to post
Share on other sites

Does c:\temp exist? It fails for me as I do not have c:\temp. If I create c:\temp, then it works fine.

Share this post


Link to post
Share on other sites

Does c:\temp exist? It fails for me as I do not have c:\temp. If I create c:\temp, then it works fine.

I duno't know what went wrong before, but it really seems to work now! :) THANKS!!

c:\temp dir exist anyway.

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