Jump to content

Execute a file only once


 Share

Recommended Posts

Is it possible to execute a file from AutoIt, such as a vbs file, and tag the file as being executed so the next time the AutoIt file is run, I can check to see if the vbs file has been executed or not? I basically want to run a vbs file but only once.

Thanks,

Link to comment
Share on other sites

Is it possible to execute a file from AutoIt, such as a vbs file, and tag the file as being executed so the next time the AutoIt file is run, I can check to see if the vbs file has been executed or not? I basically want to run a vbs file but only once.

Thanks,

you need to make a file with the script, that stores the info ($vbshasrunalready = 1 or 0 for example)

$vbshasrunalready = 0

run(vbs)

$vbshasrunalready = 1

store $vbshasrunalready in INI file (theres getini and sendini commands, or something like that)

If the script closes, savefile could be the way to go.

I'm a newb in autoIt, so i can't help you more, as im currently studying the ini/savefiles myself :)

Link to comment
Share on other sites

Maybe...

If Not FileExists(@ScriptDir & "Log.dat") Then
    Run("notepad.exe") ; or RunWait()
    FileWrite(@ScriptDir & "Log.dat", "notepad was ran " & @YEAR & "-" & @YDAY)
    MsgBox(0x0, "LOG", "The program was executed   ", 2) ; for testing only
EndIf

; your script here

MsgBox(0x0, "test", "The script was ran   ", 2)

8)

you are making me look bad, please! :)

luckily your script has more characters, so mine is shorter :) hehe

Link to comment
Share on other sites

Hi,

another concept would be renaming the exe and then check the name inside. This way you needn't an extra file!

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Maybe even better, just delete the exe after it's been ran

8)

Hmmh, I thought it has to run more than once but just avoid starting the other script more than once.

Anyhow we'll see.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Maybe...

If Not FileExists(@ScriptDir & "Log.dat") Then
    Run("notepad.exe") ; or RunWait()
    FileWrite(@ScriptDir & "Log.dat", "notepad was ran " & @YEAR & "-" & @YDAY)
    MsgBox(0x0, "LOG", "The program was executed   ", 2) ; for testing only
EndIf

; your script here

MsgBox(0x0, "test", "The script was ran   ", 2)

8)

Thank you...this work perfectly!!!!!!!!!!!

Link to comment
Share on other sites

Maybe...

If Not FileExists(@ScriptDir & "Log.dat") Then
    Run("notepad.exe") ; or RunWait()
    FileWrite(@ScriptDir & "Log.dat", "notepad was ran " & @YEAR & "-" & @YDAY)
    MsgBox(0x0, "LOG", "The program was executed   ", 2) ; for testing only
EndIf

; your script here

MsgBox(0x0, "test", "The script was ran   ", 2)

8)

Thank you...this worked perfectly!!!!!!!!!!!

Link to comment
Share on other sites

Thank you...this worked perfectly!!!!!!!!!!!

Welcome!

There are many ways of completing your request, Mega's way would work also.

However I was thinking of what you said

"I can check to see if the vbs file has been executed or not?"

That gave me the idea of the log file with the day/year that the program was ran

8)

NEWHeader1.png

Link to comment
Share on other sites

Welcome!

There are many ways of completing your request, Mega's way would work also.

However I was thinking of what you said

"I can check to see if the vbs file has been executed or not?"

That gave me the idea of the log file with the day/year that the program was ran

8)

Thanks Valuater!

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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