Jump to content

WinXP run on start-up (once)


Recommended Posts

Is there a way to run a script once, then have itself moved from Start-up directory over to a different one? Trying to run a script (exe) once after a ghost install, and then remove itself.

Well what part are you having trouble with. You can copy the exe to another dir and then use the following code to delete itself once it is done.

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc
Edited by P5ych0Gigabyte
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

That's what I'm trying to figure out. It doesn't matter how it happens, just as long as it happens the first time windows starts. Thanks for the help!

The usual way this is done, for example by many programs that make updates or uninstall, is to use the registry.

Have a key name which can be anything. In my example below I have used MOEClear1, and I have added an exclamation mark as the first character which means that if windows starts and for some reason doesn't get to execute your command then it won't delete the key. Once the command has been executed the key will be deleted.

I have a bat file in the example but it could be an exe.

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "!MOEClear1", "REG_SZ", @TempDir & "\MOETidy.bat")

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You can also use the RunOnceEx registry key to run your task before getting to the desktop..

RunOnceEx will even show a native windows dialog showing the task name at hand.

I use it on my unattended windows installs to run a whole pile of software installs and cleanup cmds before windows desktop shows.

Link to comment
Share on other sites

Hey author of this post! Suspicious case,- hope you dont creating malware.

LOL! No, if you were to search for my username on the forum, you will see that I'm compiling a script to automate a large deployment of WinXp machines. That said, this requires that I run my exe once on first start-up, then remove it, since there is no need for it after what has been done.

Thanks for your concern.

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