Siginet Posted February 6, 2006 Share Posted February 6, 2006 I am trying to search for a way to run a command within an inf file.So far I haven't really found what I am looking for. I've looked everywhere I can think of... so I thought I would ask here.I found something about RunPostSetupCommands and RunpreSetupCommands which supposedly allow you to run a command within an inf file... but it doesn't seem to do anything for me. Are these commands sopported in a windowsXP inf file?Can someone give me an idea of how I might:1. Be able to run commands from within an inf file.2. Execute a batch file or exe from within an inf file.Thanks! Link to comment Share on other sites More sharing options...
RogueSpear Posted February 6, 2006 Share Posted February 6, 2006 I always try to pay close attention to the contents of .inf files whenever I come across them, be it part of a driver package or part of a software install, and I've never seen an example where the .inf file itself initiated the execution. The closest that I have ever seen is setting the registry entries for RunOnceEx or something similar.I also did a lot of reading over at MSDN regarding .inf file programming, but was unable to put anything together. Of course part of that may be because reading MSDN brings about narcolepsy Link to comment Share on other sites More sharing options...
Shark007 Posted February 6, 2006 Share Posted February 6, 2006 Attached is the INF from windows media connect 2.It executes files (with arguments)shark Link to comment Share on other sites More sharing options...
RogueSpear Posted February 6, 2006 Share Posted February 6, 2006 (edited) Jeez, it seems so obvious now it's almost embarassing EDIT: OMG, I still can't find any documentation regarding this over at MSDN. Either I'm getting brain freeze or it's really hidden. Edited February 6, 2006 by RogueSpear Link to comment Share on other sites More sharing options...
what3v3r Posted February 7, 2006 Share Posted February 7, 2006 you could also try modifying HIVESYS.inf in order to add commands to the runonceex key, im not sure if thats what you wanted though Link to comment Share on other sites More sharing options...
Siginet Posted May 8, 2006 Author Share Posted May 8, 2006 Attached is the INF from windows media connect 2.It executes files (with arguments)sharkhmmm... I can't seem to figure out how they were able to run the file. Whenever I try to do it nothing happens. I don't think this file actually runs anything. Maybe another file checks this inf for that info to run the file? Link to comment Share on other sites More sharing options...
Delprat Posted May 8, 2006 Share Posted May 8, 2006 (edited) hmmm... I can't seem to figure out how they were able to run the file. Whenever I try to do it nothing happens. I don't think this file actually runs anything. Maybe another file checks this inf for that info to run the file?There's multiple ways to "run" INF files : in fact, INF only means "information", and what is done depends on what program reads it.The one Shark007 posted is to be parsed by update.exe (the "microsoft hotfix package installer") : to use that INF-format, you only need to have update.exe and update.inf in the same folder, and run update.exe. (but i know nothing about this syntax)."classical" INF files are parsed either by setupapi.dll (the default right click > install command on WinXP) or advpack.dll (the default right click > install command on Win9x), and only advpack.dll allows the use of RunPreSetupCommands (or RunPost...)1/ copy-paste these lines in c:\test.inf :[version]signature=$Windows NT$[DefaultInstall]RunPreSetupCommands=Test.RunPreSetupCommands[Test.RunPreSetupCommands]notepad.exe c:\test.inf2/ Run this command :rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 c:\test.infNothing works !3/ Run this command :rundll32.exe advpack.dll,LaunchINFSection c:\test.infYou'll see the contents of c:\test.inf in notepad.I didn't test with a batch, but something like "cmd.exe /c ..." should work.++edit: credits for this trick goes to jdoe : see this post Edited May 9, 2006 by Delprat Link to comment Share on other sites More sharing options...
Yzöwl Posted May 8, 2006 Share Posted May 8, 2006 If you'd like to post some more details, your file for instance, with your intentions of what you want including, it would probably help us to help you better. Link to comment Share on other sites More sharing options...
ZileXa Posted May 30, 2006 Share Posted May 30, 2006 (edited) The RunPostSetupCommands or RunPreSetupCommands only works for specific cases?[Version]Signature = $Windows NT$[DefaultInstall]ProfileItems = Shortcut.testRunPreSetupCommands=RunSetupCommands[DefaultUninstall]ProfileItems = del.shortcutsRunPostSetupCommands=RunSetupCommands[Shortcut.test]Name = "test"SubDir= cdsWorkingDir = 16422CmdLine = 16422,"cds","test"[del.shortcuts]Name = test,0x6[RunSetupCommands]cmd.exe /C SETUP.cmd ;<--- this command doesn't executeDoesn't work. (right-clicking the inf file and selecting install).I actually also tested with an .exe file, doesnt get executed Shortcut is created. Edited May 31, 2006 by ZileXa Link to comment Share on other sites More sharing options...
Yzöwl Posted May 31, 2006 Share Posted May 31, 2006 RunPreSetupCommands and RunPostSetupCommands are not standard commands recognized in an inf file, they are commands from Advanced INF. DefaultInstall uses setupapi.dll whereas Advanced INF requires advpack.dll. You therefore need to change your method of install and uninstall so that they are using the correct dll in a command line. Link to comment Share on other sites More sharing options...
ZileXa Posted May 31, 2006 Share Posted May 31, 2006 (edited) OK but isnt this strange:when I open a cmd window and run this command:rundll32.exe advpack.dll,LaunchINFSection shortcuts.infthe inf file is executed and the DefaultInstall part will execute, it will start the CMD file.BUT howcome, when I do Start>Run.. type the exact same command, press ENTER, it doesn't work! also when I rightclick it doesn't work, but thats probably because by default it uses setupapi.dll.EDIT:OK, I understand now:the working folder must be the folder containing the INF file, otherwise it wont run. So Start>Run wont work (unless the inf file is in the system32 folder)even when you specify the path like this:rundll32.exe advpack.dll,LaunchINFSection D:\i\project\app\SHORTCUTS.INF,DefaultInstallwhen you open a cmd window, go to the D:\i\project\app\ folder and use the exact same command as above, it doesn't matter if you specify path or not, will always work.So it is a little bit strange you can only run it from within the folder. But it isn't a problem for me.-----s***, thought I had everything figured out!I have a setup.cmd file with a parameter, called uninstall.the command: setup.cmd uninstall will start the uninstall section of the cmd file. This works.Now I want to use the inf file to run it (silently)[uninstall.RunSetupCommands]cmd.exe /C SETUP.cmd uninstallUnfortunately it works only without uninstall. Is it even possible?Reason I am doing all of this:it seems to me INF file are a little bit uhm inefficient, my cmd file just moves some files and adds some reg entries, creates shortcuts and then starts a pdf file. The uninstall part deletes 3 directories with files, few other files, shortcuts and a reg entry Doing all these things with the INF file seems to take a little bit more time and my harddisk makes a little more noise.So thats why I choose for 1 INF file that creates (or removes, when uninstalling) the shortcuts in start menu (better then cmd cos works for all windows languages) and then runs the Setup.cmd (for installing or uninstalling), without showing the cmd window. Seems to be the most efficient solution for an easy -one click- installer that works for all windows languages.I just create a silent 7z sfx and done.ofcourse I know vbs could work but I removed vbs support with nlite, maybe not very smart, but I actually don't need it. Edited May 31, 2006 by ZileXa Link to comment Share on other sites More sharing options...
Delprat Posted June 1, 2006 Share Posted June 1, 2006 (edited) About the "working folder"... try to use that :cmd.exe /C %01%\SETUP.cmd%01% is the folder of the inf file... this way i hope CMD.EXE will found your batchabout uninstall, did you tried :cmd.exe /C "%01%\SETUP.cmd uninstall"about all your problems : you really should learn to create InnoSetups Edited June 1, 2006 by Delprat Link to comment Share on other sites More sharing options...
Yzöwl Posted June 1, 2006 Share Posted June 1, 2006 The inf file, will uninstall without a cmd file. What you should be doing is, adding the inf to its repository within %systemroot%, adding an entry to add/remove programs, and performing the uninstall from there as you would any other program. You just have to learn how to do it properly, so continue to persue it. The only way to learn is by continuous trial and error, if you keep giving up every time you hit a hurdle, and going to another method, inno, you will never really have a good understanding. Link to comment Share on other sites More sharing options...
ZileXa Posted June 1, 2006 Share Posted June 1, 2006 (edited) I did succeed in making an inf file-only solution.. (because the CMD solution couldn't create shortcuts for all win languages easily). But I just didn't like it. it can't remove folders with its contents... and just seems to be little inefficient if I monitor my harddrive sound and time it takes to execute.That's why I now only use the inf file to create shortcuts.The other tasks are done by the cmd.And because I want cmd file to run hidden, I run the inf file first and let it start the cmd file.Ofcourse I thought about INNO setup, but I don't think it is possible to create a 1-click-only solution:double click the setup file, no window is opened, install/uninstall runs silently (hidden), when install is finished, a guide will open, giving info how to use the program that has been installed.I think installers like INNO are used if you want to give the user options. Many programs don't even have options during setup, you have to press NEXT 5 times and FINISH one time... useless. Thats why I am trying this.About the "working folder"... try to use that :cmd.exe /C %01%\SETUP.cmd%01% is the folder of the inf file... this way i hope CMD.EXE will found your batchabout uninstall, did you tried :cmd.exe /C "%01%\SETUP.cmd uninstall"about all your problems : you really should learn to create InnoSetups 1) uhm I think you mixed things up. INF file can run the CMD file, no problem there. The problem was running the INF file from Start>Run, when the INF file is somewhere in a dir like D:\projects\doubleoo\bla.inf.So that was the 'working folder' problem. But it isn't a problem anymore.2)seems it was my fault, I removed a 'pause' in the CMD file that would show me the cmd file uninstall section was executed. this works:[uninstall.RunSetupCommands]cmd.exe /C SETUP.cmd /uninstallthis also works:[uninstall.RunSetupCommands]cmd.exe /C "SETUP.cmd /uninstall"And I am pretty sure your suggestion, defining the path, would work also.btw, I modified the code of the cmd file so that I can use '/uninstall' instead of 'uninstall'. Like it is just a switch IF /I [%1]==[/uninstall] GOTO :UNINSTALLthanks for all the help. I have created "DVD ReBuilder Easy Installer", so that even my girlfriend can install the necessary apps to backup a dvdmovie, and use them. Its popular with Dutch users, didn't do any marketing on international websites because shortcuts were simply created in start menu\programs, but different languages of Windows use different names for Start menu ("Menu start" in Dutch) and programs. But now this method works fine, will release the installer on doom9/videohelp etc. Edited June 1, 2006 by ZileXa Link to comment Share on other sites More sharing options...
ZileXa Posted June 6, 2006 Share Posted June 6, 2006 (edited) I WAS WRONG!This WORKS:1[DefaultUninstall]ProfileItems = del.shortcutsRunPostSetupCommands=StartUninstall[del.shortcuts]Name = Copy DVD movies,0x6[StartUninstall]SETUP.cmd2This one, with a parameter /a for the cmd file, worksIt also works without the parameter[DefaultUninstall]ProfileItems = del.shortcutsRunPostSetupCommands=StartUninstall[del.shortcuts]Name = Copy DVD movies,0x6[StartUninstall]C:\progra~1\DVD-ReBuilder\SETUP.cmd /a3This one also works, wether there is a parameter for CMD file or not.[DefaultUninstall]ProfileItems = del.shortcutsRunPostSetupCommands=StartUninstall[del.shortcuts]Name = Copy DVD movies,0x6[StartUninstall]CMD.exe /C C:\progra~1\DVD-Rebuilder\SETUP.cmd /aplaying with quotations "" over the whole line or just the path doesn't matter4This does NOT work, parameter for CMD file doesn't make a difference:[DefaultUninstall]ProfileItems = del.shortcutsRunPostSetupCommands=StartUninstall[del.shortcuts]Name = Copy DVD movies,0x6[StartUninstall]CMD.exe /C "SETUP.cmd" also tried without the " ", doesn't work because it searches for SETUP.cmd in the %systemroot% folder.5This does NOT work either, parameter for CMD file doesn't make a difference:[DefaultUninstall]ProfileItems = del.shortcutsRunPostSetupCommands=StartUninstall[del.shortcuts]Name = Copy DVD movies,0x6[StartUninstall]CMD.exe /C %programfiles%\DVD-ReBuilder\SETUP.cmdtried C:\Program Files..., with "" and without ""... doesn't work!6Same for this one, parameter for CMD file doesn't make a difference[DefaultUninstall]ProfileItems = del.shortcutsRunPostSetupCommands=StartUninstall[del.shortcuts]Name = Copy DVD movies,0x6[StartUninstall]%programfiles%\DVD-ReBuilder\SETUP.cmdWhat I want: need %programfiles% since this has to work wether the Program Files folder is on C:\ or X:\ and is called Programs or Program Files.And I need a parameter for the cmd file, otherwise the wrong part from the CMD file will run.The CMD file and the INF file are in the same folder!About #4: Like I said in previous posts: if you first go with command prompt to the folder containing the cmd file, and then give the command to run the inf file like in #4, it does seem to work! (even with parameter).Who can help me?I tried using '16422' wich is the code for Program files... but don't know how to use it in this case.EDIT: with some tricks and different methods from Yzowl it works now. But I also discovered newest version of modified 7zS.sfx module can do A LOT of setup things like creating shortcuts (should work for all languages) and even more Edited June 13, 2006 by ZileXa Link to comment Share on other sites More sharing options...
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