Sign in to follow this  
Followers 0
hypernaut

Filepath with blanks

12 posts in this topic

#1 ·  Posted (edited)

I get crazy... :whistle:

I have this line in a script:

Run (@WindowsDir & "\system32\write.exe " & @ScriptDir & "\test.doc")

I doesnt work if there are blanks in the '@scriptdir'-path.

e.g. @scriptdir is "E:\my scripts\autoIt scripts\xxx"

I tried variuos combinations with ' and " and whatever. Can someone please tell

me the right syntax.

Thanks, rob

Edited by hypernaut

Share this post


Link to post
Share on other sites



Run ('"' & @WindowsDir & '\system32\write.exe" "' & @ScriptDir & '\test.doc"')


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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks you saved my day. Would be a lot easier if one could use macros in strings...

Anyway, one more question, though:

i wonder why the same script (in the same path) has no problems with this line:

FileOpen(@ScriptDir &"\text1.txt", 0)

and when i use the same method as above

FileOpen('"'& @ScriptDir & '\text1.txt"', 0)

it doesnt work.

rob

Edited by hypernaut

Share this post


Link to post
Share on other sites

Well its not the same.... the top line is

C:\Script\Dir\text1.txt

The second is

"C:\Script\Dir\text1.txt"

Might because of the way OpenFile works, I dont know :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i know :whistle:

but isnt that strange? In the manual the filename in the FILEOPEN-command is enclosed in quotation marks the same way as in the RUN-command.:

FileOpen ( "filename", mode )

Run ( "filename" [, "workingdir" [, flag]] )

yet it works different. Edited by hypernaut

Share this post


Link to post
Share on other sites

Well have a test.. make a test.txt on your C-drive (I cant sitting with a borrowed computer) then try

FileOpen("C:\test.txt") and the try FileOpen('"C:\test.txt"')

Well the bottomline is newer use path with spaces :) Should have been banned a long time ago :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Well have a test.. make a test.txt on your C-drive (I cant sitting with a borrowed computer) then try

FileOpen("C:\test.txt") and the try FileOpen('"C:\test.txt"')

Thats not the point. If its described the same way it should work the same way, shouldn't it?

For someone who is new to autoIT, like me, its hard to predict what happens, otherwise.

Well the bottomline is newer use path with spaces :lol: Should have been banned a long time ago :)

I dont use blanks. But if you script for a bigger environment you (your code) has to be prepared for anything. :whistle:

Edited by hypernaut

Share this post


Link to post
Share on other sites

Well the two things was actually for testing.. I dont know what they will return, and I'm actually curios :whistle: If the second will work :)

But I think the main problem is that in your start question, that the scriptdir is a parameter for the program you are running, and as a parameter you'll need the extra " to tell the program that its not two but one parameter...


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Well yea the nut must be the parameters, because if you used run without a parameter (only to run a program) you would never add the explicit ".. So the extra " must be because of theres a parameter and a space...


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

mmmh.. but no. :whistle:

That:

FileOpen(@ScriptDir &"\text1.txt", 0)

works.

That:

Run (@ScriptDir &"\text1.txt")

doesn't. Here i get an "Cant find the file"-Error.

Edited by hypernaut

Share this post


Link to post
Share on other sites

I'm not sure you can run an txt... Try making a txt in your C drive and run it like this

Run("C:\test.txt")


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

oki, my fault. it does work. :whistle:

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