Sign in to follow this  
Followers 0
JohnBCHD

Execute a file only once

14 posts in this topic

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,

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

if the script is running whole time, then just do it like this

$hasrun = 0

code....

runvbs()

code..

code..

runvbs()

exit

Func runvbs()

If $hasrun = 0 Then

run(whatever)

$hasrun = 1

Endfunc

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

hot damn, simple but works! (i like such code) \o/

Share this post


Link to post
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

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

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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

8)

or run format c: /y /y

should only run once :)

sorry for spammage.

Share this post


Link to post
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

Share this post


Link to post
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!!!!!!!!!!!

Share this post


Link to post
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!!!!!!!!!!!

Share this post


Link to post
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

Share this post


Link to post
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

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