Sign in to follow this  
Followers 0
Autoxics

File Path At The Wrong Place? Where Have I Gone Wrong?

14 posts in this topic

This works fine when the script is anywhere execpt in the temp folder it does not work,

well the first part does , as if Notepad is running, but the else statment does not if notepad in not running

however booth statments works well if the script is execute in from another directory , like C:\

$var = ProcessExists("Notepad.exe")
If ProcessExists("Notepad.exe") Then 
    MsgBox(4096, "", "Notepad Is Running.")
Else
If @compiled Then
Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @ScriptFullPath, "D:/.", @SW_HIDE)
Sleep (10)
EndIf
EndIF
Exit

So i figured it must be a missing @TempDir so i tried this but with no luck

Where have i gone wrong?

Please try out the code if you want to.

$var = ProcessExists("Notepad.exe")
If ProcessExists("Notepad.exe") Then 
    MsgBox(4096, "", "Notepad Is Running.")
Else
If @compiled Then
Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @TempDir & @ScriptFullPath, "D:/.", @SW_HIDE)
Sleep (10)
EndIf
EndIF
Exit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @TempDir & @ScriptFullPath, "D:/.", @SW_HIDE)

That doesn't look right (in red).

Edit:

Also your @TempDir & @ScriptFullPath doesn't make much sense either....

My suggestion is for you to debug like this at the top:

MsgBox(0, 'Info', @TempDir & @ScriptFullPath)
so you can see for yourself. Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

this cant be right either

@TempDir & @ScriptFullPath

8)

Aw,,, smoke came back and got that one too..

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Aw,,, smoke came back and got that one too..

lol, Although I don't play with run commands often, nor do I mess with del at all, I would imagine that you would need a space after del as well.

[center]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.[/center]

Share this post


Link to post
Share on other sites

I get an error on that one "Incorrect Number of parameters"

Share this post


Link to post
Share on other sites

I get an error on that one "Incorrect Number of parameters"

What did you try?... I said that D:/. doesn't look right... Try just putting "" there.

[center]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.[/center]

Share this post


Link to post
Share on other sites

I put the compile script here

C:\Documents and Settings\Administrator\Local Settings\Temp

and i used this

$var = ProcessExists("Notepad.exe")
If ProcessExists("Notepad.exe") Then 
    MsgBox(4096, "", "Notepad Is Running.")
Else
If @compiled Then
Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @TempDir & @ScriptFullPath, "", @SW_HIDE)
Sleep (10)
EndIf
EndIF
Exit

Share this post


Link to post
Share on other sites

I put the compile script here

C:\Documents and Settings\Administrator\Local Settings\Temp

and i used this

$var = ProcessExists("Notepad.exe")
If ProcessExists("Notepad.exe") Then 
    MsgBox(4096, "", "Notepad Is Running.")
Else
If @compiled Then
Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @TempDir & @ScriptFullPath, "", @SW_HIDE)
Sleep (10)
EndIf
EndIF
Exit
Did you try the Message Box I put up there... or did I just type it for fun? You'll see what your problem is.

[center]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.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I tried it out to put this ontop of my script

MsgBox(0, 'Info', @TempDir & @ScriptFullPath)

I runed the script in

C:\Documents and Settings\Administrator\Local Settings\Temp

I get a message box with path, but i dont know how to use that info

in the correct way

Edited by Autoxics

Share this post


Link to post
Share on other sites

This is the box i get , Should i put this exact name in between the ""

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

This is the box i get , Should i put this exact name in between the ""

Ugh!!

Look at it... does that look right? You have 2 paths there. Just use @ScriptFullPath :(:think:

Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Ok i just use this now one of the path i got from the messagebox inbetween this" "

and i just use @ScriptFullPath

Like this

$var = ProcessExists("Notepad.exe")
If ProcessExists("Notepad.exe") Then 
    MsgBox(4096, "", "Notepad Is Running.")
Else
If @compiled Then
Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @ScriptFullPath, "C:\Documents and Settings\Administrator\Local Settings\Temp\", @SW_HIDE)
Sleep (10)
EndIf
EndIF
Exit

But it dont work

Edited by Autoxics

Share this post


Link to post
Share on other sites

Ok i just use this now one of the path i got from the messagebox inbetween this" "

and i just use @ScriptFullPath

Like this

$var = ProcessExists("Notepad.exe")
If ProcessExists("Notepad.exe") Then 
    MsgBox(4096, "", "Notepad Is Running.")
Else
If @compiled Then
Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @ScriptFullPath, "C:\Documents and Settings\Administrator\Local Settings\Temp\", @SW_HIDE)
Sleep (10)
EndIf
EndIF
Exit

But it dont work

What are you trying to do exactly?

[center]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.[/center]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

No Worriys i got it working! :think:

I want to use this on a project i am working on witch if a cetaint process is running i want to keep the script alive and as soon as a that certain process is not active anymore i want the script exits and deletes itself right away, you been a great help here, i ve been scratching my brain substanse here trying to figure it out and it was pretty simple ones i tried out a few codes from the help @ScriptName that was the fellow that did it ! :( anyway here is the code if anyone ellse needs it!

And thank you SmOke_N for trying to figure it out and helping me, without you i dont think id manage to solve it, Great forum support, and as a thank you to the forum and for this free terrific applications i have decided to donate a few bucks to the development of Autoit, so you guys gets some credits for the help you give. Any help is most appriciated

And the help ive got so far is to good to be true!thanks for doing what you guys do!

I hope to be able to help others out aswell, when ive become more than a noob

$var = ProcessExists("Notepad.exe")
If ProcessExists("Notepad.exe") Then 
    MsgBox(4096, "", "Notepad Is Running.")
Else
If @compiled Then
Run(@ComSpec & " /c " & 'ping -n 1 localhost & del ' & @ScriptName, "", @SW_HIDE)
Sleep (10)
EndIf
EndIF
Exit
Edited by Autoxics

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