Jump to content

running a .reg file


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Developers

Just use ShellExecuteWait() in stead of runwait()

PS: RunWait() doesn't return a PID but the ExitCode.

Edited 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.
  :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Das Häschen benutzt Radar

Link to comment
Share on other sites

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

Since 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 by Squirrely1

Das Häschen benutzt Radar

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