claxton Posted March 24, 2008 Posted March 24, 2008 I am new here so be gentle please. I am trying to write a script that will 1) install a registry key and 2) delete itself or remove itself from its current directory to a specified one. I need to put this script in the startup folder to add a key and then move itself or or delete itself so it does not run over and over on log in. This is for a mass F@H borg project. I don't want to disrupt the work of the users that are currently using the machines and just want this to run the next time the user logs in. It also needs to be run as a specific account. I know this is a lot to ask, but I am new to autoit. If there is some reading you could suggest online, I am willing to do the research.
MDCT Posted March 24, 2008 Posted March 24, 2008 If I'm not mistaken there is a function that could convert .reg to the .au3. But, I believe it would take more CPU and time compared to using reg.exe and regedit.exe. Here is what I used to import .reg using reg.exe: $PID=RunWait('Reg import "FileName.reg"' ,@WorkingDir,@SW_HIDE) While ProcessExists($PID) Sleep(5) WEnd To prevent the .reg getting imported twice, instead delete or move the .reg. You could check if the key is already available in the system registry, by using: RegEnumKey("HKEY_CURRENT_USER\Software\XYZ", 1) If @error <> 0 then Hope this helps.
Developers Jos Posted March 24, 2008 Developers Posted March 24, 2008 (edited) Just use ShellExecuteWait() in stead of runwait() PS: RunWait() doesn't return a PID but the ExitCode. Edited March 24, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Legacy99 Posted March 24, 2008 Posted March 24, 2008 Quick and dirty, this is how I would do it. RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","RunMeOnce","REG_SZ", 'regedit /s "C:\Regfile.reg"') If your running it from a logon script, the user must logon once and the pc reboot once for this to apply.
Squirrely1 Posted March 24, 2008 Posted March 24, 2008 (edited) ... I need to put this script in the startup folder to add a key and then move itself or or delete itself so it does not run over and over on log in.This key is used on my machine to run the given file only at the next bootup: ;Register a file to run once: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "SquirrelyStartupScript", "REG_SZ", "C:\filepath.exe") Embed the "C:\filepath.exe" with double-quotes if it has spaces in it, this way: '"C:\my filepath.exe"' Edited March 25, 2008 by Squirrely1 Das Häschen benutzt Radar
Squirrely1 Posted March 24, 2008 Posted March 24, 2008 (edited) This is for a mass F@H borg project. I don't want to disrupt the work of the users that are currently using the machinesSince it's for one of those Borg machines that runs just about any variety of operating systems simultaneously, you could try one of those interplanetary porting systems for "programming technical data". The planet Sot has some programmers on it and some of the oldest books on the subject - a good one was published at earth-date c. 1905 A.D. Edited March 24, 2008 by Squirrely1 Das Häschen benutzt Radar
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now