Jump to content

Do Something Once


Recommended Posts

Perhaps something with a .ini

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

Run("notepad")
WinWait("Untitled - Notepad")

For $i = 1 To 3
    If $i = 1 Then
        MsgBox(0, "", "First time thru the loop")
    Else
        ControlSend("Untitled - Notepad", _
                "", "Edit1", _
                "This is loop number " _
                 & $i & @CR)
    EndIf
Next
or
Run("notepad")
WinWait("Untitled - Notepad")

For $i = 1 To 3
    If $i = 1 Then MsgBox(0, "", "First time thru the loop")

    ControlSend("Untitled - Notepad", _
            "", "Edit1", _
            "This is loop number " _
             & $i & @CR)
Next

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Can someone make a example of that with notepad, that there's popping up a msgbox once? at first startup

Hi,

Here is a very simple thing we do in our login.bat batch file:

CD %userprofile%

If Exist Client.txt Goto EndClient

\\x_server\Update\Client\xyz.exe /s

echo Client installed >>Client.txt
attrib Client.txt +R +H

:EndClient

The CD place the working dir in the user profile and create a file .txt in it then hide it. next time it starts the file exists and nothing is don anymore...

you can easily do it with AutoIt in the @TempDir for example...

Link to comment
Share on other sites

But if I run the last script again it still displays the msgbox

Well now I know for sure what you want... maybe NightGaunt will be willing to post an example of "Or set a HKCU regkey if you don't like ini files..."

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

The registry functions here seem useful:

http://www.autoitscript.com/forum/index.ph...545&hl=registry

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

Well now I know for sure what you want... maybe NightGaunt will be willing to post an example of "Or set a HKCU regkey if you don't like ini files..."

Dim $Registry = "HKCU\AutoItRo\"
Dim $RegKey = "Start"
Dim $RegCheck
;Dim $RegValue (Not Used, I was going to use this to increment)


$RegCheck = RegRead ($Registry, $Regkey)
if @error = 1 Then  regwrite ($Registry, $Regkey, "Reg_SZ", "0");(Basically if it doesn't exist create and set to 0)

$RegCheck = RegRead ($Registry, $Regkey)
if $RegCheck = 0 then 
    msgbox (0x10, "Fight Club", "You do not talk about fight club.")
    regwrite ($Registry, $Regkey, "REG_SZ", "1")
EndIf
if $RegCheck = 1 Then
    msgbox (0x10, "Fight Club", "Tyler Durden Says: Use Soap")
    regwrite ($Registry, $Regkey, "REG_SZ", "2")
EndIf

If I was really doing this I may set a numerical key for the "2" and "1" and then increment it. But this "quick and dirty" method should clear it up.

"I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal
Link to comment
Share on other sites

Or, as mentioned by Infinitex0, an ini file.

$file_ini = @AppDataDir & '\MyProgram\Settings.ini'
If Not FileExists($file_ini) Or Not Int(IniRead($file_ini, 'section', 'intro', 0)) Then
    MsgBox(0, '', 'This program has not been used yet')
    DirCreate(@AppDataDir & '\MyProgram')
    IniWrite($file_ini, 'section', 'intro', 1)
EndIf
Link to comment
Share on other sites

Thanks

There's also the registry keys:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

and

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

You can create a key with a string value of the command you want to run.

If you put it in HKCU, it will run the next time that user logs in, and then the key self deletes.

If you use HKLM, it will run for the next person that logs in and then self delete.

Typically you use HKLM unless you're setting up an image which will be SysPrep'd in which case you'd want to put an entry in the key:

HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\RunOnce

and then the first time a new user logs in, whatever is in that key will run once for that user.

See:

Using RunOnce Technology

J

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