Jump to content

@ScriptDir quit working


Recommended Posts

  • Moderators

I am no longer able to use the @ScriptDir command to launch programs. Is this a known issue?

Was working:

$keepass = @ScriptDir & "\KeePass.exe"

My script path is:

"C:\Documents and Settings\username\My Documents\- Tools"

CC

Did you check the value of $keepass and verify?

Do you know what OS this is failing on?

Does it fail in every situation on every script?

Does it fail only compiled?

Do you have a replication script?

We shouldn't really have to ask these questions... should we?

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.

Link to comment
Share on other sites

Yes I verified I can launch the application via command line with the same path. I also put a MessageBox to verify the path I was using was correct it was. This has been working for me for quite a long time. I don't know what changed but obviously something has.

I am running 3.3.0.0

Here are the application snippets:

$stopwatch = @ScriptDir & "\stopwtch.exe" ;<--Yes the spelling is correct for the application.

$Button7 = GUICtrlCreateButton("Timer", 20, 263, 89, 23, 0)

GUICtrlSetOnEvent($Button7, "Timer")

Func Timer()

Run($stopwatch)

If @error Then

SplashTextOn("Notice - Error", " Your stopwatch command failed." & @CRLF & "No stopwatch application was found." & @CRLF, 380, 65)

Sleep(3000)

SplashOff()

EndIf

EndFunc ;==> Timer

CC

Link to comment
Share on other sites

Yes I verified I can launch the application via command line with the same path. I also put a MessageBox to verify the path I was using was correct it was. This has been working for me for quite a long time. I don't know what changed but obviously something has.

I am running 3.3.0.0

Here are the application snippets:

$stopwatch = @ScriptDir & "\stopwtch.exe" ;<--Yes the spelling is correct for the application.

$Button7 = GUICtrlCreateButton("Timer", 20, 263, 89, 23, 0)

GUICtrlSetOnEvent($Button7, "Timer")

Func Timer()

Run($stopwatch)

If @error Then

SplashTextOn("Notice - Error", " Your stopwatch command failed." & @CRLF & "No stopwatch application was found." & @CRLF, 380, 65)

Sleep(3000)

SplashOff()

EndIf

EndFunc ;==> Timer

CC

You haven't really told us much apart from that you can't get it to work.

What does this produce?

$file = "stopwtch.exe"
If FileExists($file) Then
    ConsoleWrite($file & " is in the scriptdir" & @CRLF)
Else
    ConsoleWrite($file & " is not in the script dir" & @CRLF)
    Exit
EndIf

If FileExists(@ScriptDir & "\" & $file) Then
    ConsoleWrite("The @SCriptDir macro is working fine" & @CRLF)
Else
    ConsoleWrite("The @SCriptDir macro is not working." & @CRLF)
EndIf
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

Yes I verified I can launch the application via command line with the same path. I also put a MessageBox to verify the path I was using was correct it was. This has been working for me for quite a long time. I don't know what changed but obviously something has.

I am running 3.3.0.0

Here are the application snippets:

$stopwatch = @ScriptDir & "\stopwtch.exe" ;<--Yes the spelling is correct for the application.

$Button7 = GUICtrlCreateButton("Timer", 20, 263, 89, 23, 0)

GUICtrlSetOnEvent($Button7, "Timer")

Func Timer()

Run($stopwatch)

If @error Then

SplashTextOn("Notice - Error", " Your stopwatch command failed." & @CRLF & "No stopwatch application was found." & @CRLF, 380, 65)

Sleep(3000)

SplashOff()

EndIf

EndFunc ;==> Timer

CC

Command Line?

Do you mean cmd.exe?

Do you mean Run()?

You can't have spaces in a path name without surrounding them with quotes.

Run("C:\mypath\long folder name\runexe.exe")

Will not work because it will only get broken up like:

C:\mypath\long

folder

name\runexe.exe

You have to ensure that the path is properly double quoted:

Run('"' & @ScriptDir & "\runexe.exe" & '"')

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.

Link to comment
Share on other sites

It's really puzzling. Your script indicates the application is in the script directory and the macro is working fine. I have used the same script for over a year and never had any problems. On Friday it quit working for applications that were launched using the @ScriptDir & "\application.exe" syntax. Interesting enough I thought how hard can this be, really!!! I rename the - Tolls directory to Tolls and retried. It didn't work. I then moved the application to the root of the C: drive, c:\tools and it works successfully.

The only thing that might be considered unusual is the path name I had used:

C:\Documents and Settings\username\My Documents\- Tools

I renamed the folder and changed the path to:

C:\Documents and Settings\username\My Documents\Tools

and it still won't run.

I moved the file to C:\tools and they work with the script unmodified+.

The code used was:

$stopwatch = @ScriptDir & "\stopwtch.exe" ;<--Yes the spelling is correct for the application.

$Button7 = GUICtrlCreateButton("Timer", 20, 263, 89, 23, 0)

GUICtrlSetOnEvent($Button7, "Timer")

Func Timer()

Run($stopwatch)

If @error Then

SplashTextOn("Notice - Error", " Your stopwatch command failed." & @CRLF & "No stopwatch application was found." & @CRLF, 380, 65)

Sleep(3000)

SplashOff()

EndIf

EndFunc ;==> Timer

CC

Link to comment
Share on other sites

  • Moderators

You're probably reading my post... but just to help you along:

Run('"' & $stopwatch & '"')

Because your last post confirmed the suspicion of spaces in the path name.

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.

Link to comment
Share on other sites

Can you add a ConsoleWrite or some type of debug statement so we can see what it is. Even maybe a FileExists function to make sure it's getting there. I've had some interesting times with quotes before switching os's and service packs or me being tired. Maybe try that.

On a site note KeePass kicks ass and PortableApps.com has a portable ported version of it if you are trying to make a launcher for it you can try that one instead. I hope this helps.

-avery

www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
Link to comment
Share on other sites

You're probably reading my post... but just to help you along:

Run('"' & $stopwatch & '"')

Because your last post confirmed the suspicion of spaces in the path name.

I'm not sure the spaces are the problem because if I try running a script from my script directory using

Run("ScriptDir & "\someexe.exe")

then it works ok. My script directory has spaces in it.

But I think the quotation marks are essential if the path has minus sign in it.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I must have been really lucky!! Sm0ke_N you were absolutely correct, thanks a lot!!! I had used the incorrect syntax in my script. I can't believe it has worked for over a year without any issue until last week. I don't know what triggered it to fail but it works as expected know.

Puzzling thing is Martin's suggested script indicated everything was OK. I bow to you guys superior intellect :)

You guys are awesome!!! Thanks again.

CC

Link to comment
Share on other sites

A couple points of clarification:

Script had been running for over a year without any issues.

Application could be launched via command line (cmd) or using start run and started successfully.

I suspected the - Folder in the path could be causing my issue for I removed this from the path name and it still didn't work.

Moved all of the file to c:\tools and it worked correctly. Obviously a path issue.

I was puzzled as to why it quit but then realized I had upgrade my Autoit to the latest 3.3.0.0 version last week. Perhaps the previous version didn't have an issue with the path and the new version required the correct syntax.

CC

Link to comment
Share on other sites

A couple points of clarification:

Script had been running for over a year without any issues.

Application could be launched via command line (cmd) or using start run and started successfully.

I suspected the - Folder in the path could be causing my issue for I removed this from the path name and it still didn't work.

Moved all of the file to c:\tools and it worked correctly. Obviously a path issue.

I was puzzled as to why it quit but then realized I had upgrade my Autoit to the latest 3.3.0.0 version last week. Perhaps the previous version didn't have an issue with the path and the new version required the correct syntax.

CC

It looks to me like we're all wrong so far.

I created a folder "-Tools"

Then I ran this

ConsoleWrite(@scriptdir & @CRLF)
Run(@scriptdir & "\test.exe");No quotation marks

and it ran fine. The script directory is

C:\Documents and Settings\Martin\Local Settings\Temp\-Tool

and I'm using 3.3.0.0.

So I don't know the answer.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Martin- The only difference between your path and mine was a space:

You used:

C:\Documents and Settings\Martin\Local Settings\Temp\-Tool

I was using:

C:\Documents and Settings\Martin\Local Settings\Temp\- Tool

CC

Edited by IvanCodin
Link to comment
Share on other sites

Martin- The only difference between your path and mine was a space:

You used:

C:\Documents and Settings\Martin\Local Settings\Temp\-Tool

I was using:

C:\Documents and Settings\Martin\Local Settings\Temp\- Tool

CC

Yes but you have alreday tried

C:\Documents and Settings\username\My Documents\Tools

which didn't work.

I added a space and it still works. I added a space beforer the '-' and tried this

ConsoleWrite(@scriptdir & @CRLF)
$p = @ScriptDir & "\test.exe"
FileChangeDir("D:\")
run($p )

and it still works. It looks to me as though Run must add it's own quotation marks if needed.

The only thing I can see that might be the problem is the username in the path; I assume it isn't actually "username"

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I don't know if this is a valid test but I modified my script to send the string to a file. If I remove the '"' syntax from the function it still doesn't run, so I changed it back. Here is what I modified:

Func Timer()

$file = FileOpen ("c:\info.txt", 1)

FileWrite ($file, "This is the output with tick quote syntax:" & @CRLF)

FileWrite ($file, '"' & $stopwatch & '"' & @CRLF)

FileWrite ($file, " And this is the output without:" & @CRLF)

FileWrite ($file, $stopwatch)

FileClose($file)

Run('"' & $stopwatch & '"') ; <===If I remove the '"' it won't run

If @error Then

SplashTextOn("Notice - Error", " Your stopwatch command failed." & @CRLF & "No stopwatch application was found." & @CRLF, 380, 65)

Sleep(3000)

SplashOff()

EndIf

EndFunc ;==> Timer

Here is the output of the function when I ran it:

This is the output with tick quote syntax:

"C:\Documents and Settings\cclausen\My Documents\Tools\stopwtch.exe"

And this is the output without:

C:\Documents and Settings\cclausen\My Documents\Tools\stopwtch.exe

To me it looks like either should work. As I mentioned above this may be an invalid as Autoit may handle the output differently when sending to file.

CC

Edited by IvanCodin
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...