Sign in to follow this  
Followers 0
anyday

Running A Set Of Commands Once

6 posts in this topic

is it possible to run a few commands at the start of the script only the first time the script is ruN?

Share this post


Link to post
Share on other sites



yes it is you just have to write a value somewhere or have a specific thing that you can only see when you've already run the script once

e.g.

if not fileexist (@tempdir & "\checkfile.chk") then
;do whatever you want to do at first start
filewriteline (@tempdir & "\checkfile.chk", ".")
endif
;here is the rest of your script

hope this helps you

Share this post


Link to post
Share on other sites

yea thanks man i will try it out, but yea seems like that would do it.

Share this post


Link to post
Share on other sites

To ensure it is the 1st code executed, then you can use OnAutoItStart(). AutoIt will look for this function as the 1st code to run before anything else.

Func OnAutoItStart()
;Code here
;...
;...
EndFunc

:)

Share this post


Link to post
Share on other sites

HI,

if you know that it is the first run you can also do something like this

If $CmdLine[0] > 0 And $CmdLine[1] = "firstRun" Then
do some stuff
Endif

So long,

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

#6 ·  Posted (edited)

Nuffilein805,

I get the following error with your code

if not fileexist (@ScriptDir & "\checkfile.chk") then

if not ^ERROR

Error: Unknown function name.

n/m i see the prob should be FileExists

Works great, thanks

-------------------------------

MHz

The code you posted works good but it runs every time the script is ran i only need it to run the very first time a user runs the script

Edited by anyday

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