Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


LeveL

Cannot set a reg entry by installing from an INF file

9 posts in this topic

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!

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
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
0

Share this post


Link to post
Share on other sites

Is the batch file in place after install (just no execute), or did it not copy over at all?

0

Share this post


Link to post
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"

0

Share this post


Link to post
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.

0

Share this post


Link to post
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.

0

Share this post


Link to post
Share on other sites

I never got the exclamation point trick to work with runonce, but placing it before your key is supposed to prevent deletion.

0

Share this post


Link to post
Share on other sites

OK thanks, yes I will probably switch to RunOnceEx at some point.

0

Share this post


Link to post
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.