Jump to content

Why does "Run" not work anymore? EVER?!


Recommended Posts

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\TPT_Watcher.exe"
Run($name, $path)

Why does that not work?

I copy and pasted the name, and the path.

Please reply. Thanks.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\TPT_Watcher.exe"
Run($name, $path)

Why does that not work?

I copy and pasted the name, and the path.

Please reply. Thanks.

Just as a stab in the dark, (I am not sure if its right) but as a guess, try deleing the .exe from the path

so then

$path = C:\Autoit3\Folder_Protector\

again, just a guess

Link to comment
Share on other sites

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\TPT_Watcher.exe"
Run($name, $path)

Why does that not work?

I copy and pasted the name, and the path.

Please reply. Thanks.

You are trying to run "TPT_Watcher.exe" which is a relative path and not a absolute path (fullpath).

A relative path is seen by the script as to the Working Directory of the script as of that line being processed. When using relative addressing, the script should always check 1st what the working directory is. Checking includes if the script is in the same directory as "TPT_Watcher.exe" as the working directory is not always @ScriptDir.

With the above code, I could not be sure of where your script is and what the working directory is. The working directory parameter of Run() is passed onto the executeble and is not the working directory of the script. FileChangeDir() changes the working directory of the script if needed.

To ensure Run() will work, then you need to be sure the executables path is seen by the script.

Some examples below.

; Script is in the @ScriptDir
$name = @ScriptDir & "\TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector"
Run($name, $path)


; Script is in the @ScriptDir
If @WorkingDir <> @ScriptDir Then
    FileChangeDir(@ScriptDir)
EndIf
$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector"
Run($name, $path)


; Script is NOT in the @ScriptDir
$name = "C:\AutoIt3\Folder_Protector\TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector"
Run($name, $path)


; Script is NOT in the @ScriptDir
If FileChangeDir("C:\AutoIt3\Folder_Protector") Then
    $name = "TPT_Watcher.exe"
    Run($name)
EndIf

:D

Link to comment
Share on other sites

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\TPT_Watcher.exe"
Run($name, $path)

Why does that not work?

I copy and pasted the name, and the path.

Please reply. Thanks.

Why you using variables?

Run("TPT_Watcher.exe","C:\AutoIt3\Folder_Protector\TPT_Watcher.exe")
;;;;;;;Not tested;;;;;;;;;

i542

I can do signature me.

Link to comment
Share on other sites

The second parameter in the Run command is the working directory, not the pathname of the executable. The following will not work because the second parameter, $path, is a filename, but it must be the name of a directory, or else the command will fail:

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\TPT_Watcher.exe"
Run($name, $path)

However, this should work (untested; you may not need the final backslash in the $path):

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\"
Run($name, $path)
Edited by Edward Mendelson
Link to comment
Share on other sites

The second parameter in the Run command is the working directory, not the pathname of the executable. The following will not work because the second parameter, $path, is a filename, but it must be the name of a directory, or else the command will fail:

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\TPT_Watcher.exe"
Run($name, $path)

However, this should work (untested; you may not need the final backslash in the $path):

$name = "TPT_Watcher.exe"
$path = "C:\AutoIt3\Folder_Protector\"
Run($name, $path)
Please read my last post. When using relative addressing, always check the working directory of the script.

For example, if the script is executed from the registry, then @HomeDrive will be the working directory and finding "TPT_Watcher.exe" will fail if it is not there. :D

Link to comment
Share on other sites

I almost forgoted. So try this:

;;;;Not tested;;;;;

Global $name = "TPT_Watcher.exe"

Global $path = "C:\AutoIt3\Folder_Protector\"

Run($name,$path)

If @error Then MsgBox(16,"Error","It doesn' t work :(")

Or if you think Run command really NEVER doesn't work try to run some else program to test it, for example Notepad. If Run really never doesn't work (if fail on Notepad) try download new beta.

i542

I can do signature me.

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