Jump to content

Cannot set a reg entry by installing from an INF file


Recommended Posts

I searched Google and this forum, nothing I have tried works.

I want to add a reg entry under:

HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce

This should be straightforward - just put this line in HIVESFT.INF where RunOnce appears:

HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","MyEntry",0x00000000,"MyFile.bat"

1 - MyFile.bat is already in %systemroot%\

2 - It doesn't need the path, just referencing the bat file has worked in the past.

I have been trying for hours now, over 2 days and nothing works.

I put an INF file on the desktop that says:

[Version]
Signature = "$Windows NT$"

[DefaultInstall]
AddReg = StartRunOnce

[StartRunOnce]
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","MyEntry",0x00000000,"MyFile.bat"

But if I right click this INF and check in the registry under that key, the entry "MyEntry" is not there.

I have tried every single way I can think now, searched Google, searched here, no one seems to have this problem.

What do I need in the INF file to make it work?

Be prepared for every single suggestion to fail by the way. Thats if anyone even has anything to suggest, theres only one way to do this and I have tried so many varied lines now, I must have used the correct syntax at least once!

Link to comment
Share on other sites


The batch file needs to go in to %SystemRoot%\System32 if you don't want to specify a path.

Aside from that having nothing to do with it entering data under a reg key from an INF file, you're wrong anyway.

It doesn't, it goes in %systemroot% and that doesn't need any path.

I already know this looking for example at the file in my WINDOWS folder called "RTHDCPL.EXE" that is a program for my sound card - see, pathless and it does run...

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"RTHDCPL"="RTHDCPL.EXE"

Thats all that says plus I know it works because I have done it before, thats why I am doing it this way now.

Please stop confusing things. Or don't reply if you don't know!

But for now I am not even at that point and don't want to jump the gun here when the very initial thing isn't even working.

Just downloaded this from RyanVM:

[Tool] Reg2Inf converter v0.46

http://www.ryanvm.net/forum/viewtopic.php?t=2169

It gave me this converted to INF (from a reg file I know for certain does work to put the entry in, as a reg file)

[Version]
Signature = "$Windows NT$"

[DefaultInstall]
AddReg = REGEntries.AddReg

[REGEntries.AddReg]
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","MyEntry",0x0,"MyFile.bat"

Nice, the 0x00000000 has changed to 0x0, I had my hopes up there for a minute but guess what - does not work.

Nothing anyone can suggest could make it work, I don't even know why I am asking. :}

Thats not to say people here are daft I am saying there IS no answer.

All I can think is the registry is broken, or locked down in some way even though I am the Administrator logged in as Administrator, why oh why isn't any of this working?

I have tried countless times now right clicking an INF to "install" it into the registry and its not working.

PS yes if I do "REG ADD" in a batch file that works perfectly, but even then the batch file is being deleted from the WINDOWS folder and I don't know why. Its supposed to run on next reboot not just vanish off the face of the earth, but nevermind, I am not even at that point yet, all I want to solve is this INF and to make it put the entry in.

No, the answer isn't anything other than putting a line in HIVESFT.INF it must go there, please don't suggest anything else when this is what I need to do. People always say do this and do that but I tried it hours ago, or can't do it.

Edited by LeveL
Link to comment
Share on other sites

[Version]
Signature = "$Windows NT$"

[DefaultInstall]
AddReg = REGEntries.AddReg

[REGEntries.AddReg]
HKLM,%RunOnce%
HKLM,%RunOnce%,"MyEntry",,"MyFile.bat"

[Strings]
RunOnce="SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"

Link to comment
Share on other sites

Thanks but I found out that the RunOnce key cannot "hold" an entry, thats why it does not appear there, it does appear but vanishes in like 0.00001 seconds.

Im doing it under another key now and will just have to fix it later to stop it running on every reboot.

So there you go - the RunOnce key might as well not be there because you can't add anything to it, not using an INF anyway.

Link to comment
Share on other sites

When adding RunOnce keys via an INF install they are run immediately after the INF install completes.

From: http://support.microsoft.com/kb/281820

All RunOnce entries in the registry are run in the following cases:

1. At the end of installation through InstallFromHinfSection even in the cases where you must restart the computer.

2. After the default processing of DIF_INSTALLDEVICE even if you must restart the computer (with the exception of server-side processing).

3. After the system has been restarted.

Further down the same page:

Programs that must run once when the computer is restarted should be specified through RunOnceEx entries.

You should be seeing one of two things when you run the INF you provided, either an error that myfile.bat is not a valid win32 application, or you see you bat file flash on the screen as it runs.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...