MSFN Forum: RunPostSetupCommands - MSFN Forum

Jump to content


Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

RunPostSetupCommands Inf File Question? Rate Topic: -----

#1 User is offline   Siginet 

  • Windows XP PowerPacker Creator
  • PipPipPipPipPip
  • Group: Members
  • Posts: 736
  • Joined: 22-January 05

Posted 05 February 2006 - 10:16 PM

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!


#2 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 06 February 2006 - 04:09 PM

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 :P

#3 User is offline   Shark007 

  • Repackaging Specialist
  • PipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 3,154
  • Joined: 07-January 04

Posted 06 February 2006 - 04:18 PM

Attached is the INF from windows media connect 2.
It executes files (with arguments)

shark

#4 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 06 February 2006 - 04:23 PM

Jeez, it seems so obvious now it's almost embarassing :blushing:

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.

This post has been edited by RogueSpear: 06 February 2006 - 04:40 PM


#5 User is offline   what3v3r 

  • Member
  • PipPip
  • Group: Members
  • Posts: 184
  • Joined: 07-August 04

Posted 06 February 2006 - 07:25 PM

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 :unsure:

#6 User is offline   Siginet 

  • Windows XP PowerPacker Creator
  • PipPipPipPipPip
  • Group: Members
  • Posts: 736
  • Joined: 22-January 05

Posted 07 May 2006 - 06:11 PM

View PostShark007, on Feb 6 2006, 05:18 PM, said:

Attached is the INF from windows media connect 2.
It executes files (with arguments)

shark

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?

#7 User is offline   Delprat 

  • Poll: Why are you reading this ?
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 18-May 05

Posted 08 May 2006 - 06:33 AM

View PostSiginet, on May 8 2006, 01:11 AM, said:

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


2/ Run this command :
rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 c:\test.inf
Nothing works !

3/ Run this command :
rundll32.exe advpack.dll,LaunchINFSection c:\test.inf
You'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

This post has been edited by Delprat: 09 May 2006 - 01:17 AM


#8 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,363
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 08 May 2006 - 08:11 AM

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.

#9 User is offline   ZileXa 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 767
  • Joined: 27-May 04

Posted 30 May 2006 - 01:29 PM

The RunPostSetupCommands or RunPreSetupCommands only works for specific cases?
[Version]
Signature = $Windows NT$


[DefaultInstall]
ProfileItems = Shortcut.test
RunPreSetupCommands=RunSetupCommands

[DefaultUninstall]
ProfileItems = del.shortcuts
RunPostSetupCommands=RunSetupCommands


[Shortcut.test]
Name = "test"
SubDir= cds
WorkingDir = 16422
CmdLine = 16422,"cds","test"

[del.shortcuts]
Name   = test,0x6


[RunSetupCommands]
cmd.exe /C SETUP.cmd ;<--- this command doesn't execute

Doesn't work. (right-clicking the inf file and selecting install).
I actually also tested with an .exe file, doesnt get executed :(
Shortcut is created.

This post has been edited by ZileXa: 31 May 2006 - 08:39 AM


#10 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,363
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 May 2006 - 09:03 AM

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.

#11 User is offline   ZileXa 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 767
  • Joined: 27-May 04

Posted 31 May 2006 - 04:26 PM

OK but isnt this strange:
when I open a cmd window and run this command:
rundll32.exe advpack.dll,LaunchINFSection shortcuts.inf
the 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,DefaultInstall

when 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 uninstall

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

This post has been edited by ZileXa: 31 May 2006 - 05:07 PM


#12 User is offline   Delprat 

  • Poll: Why are you reading this ?
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 18-May 05

Posted 01 June 2006 - 01:39 AM

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 batch

about uninstall, did you tried :
cmd.exe /C "%01%\SETUP.cmd uninstall"

about all your problems : you really should learn to create InnoSetups :lol:

This post has been edited by Delprat: 01 June 2006 - 01:39 AM


#13 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,363
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 01 June 2006 - 02:36 AM

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.

#14 User is offline   ZileXa 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 767
  • Joined: 27-May 04

Posted 01 June 2006 - 07:55 AM

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.


View PostDelprat, on Jun 1 2006, 09:39 AM, said:

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 batch

about uninstall, did you tried :
cmd.exe /C "%01%\SETUP.cmd uninstall"

about all your problems : you really should learn to create InnoSetups :lol:

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 /uninstall

this 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 :UNINSTALL


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

This post has been edited by ZileXa: 01 June 2006 - 08:01 AM


#15 User is offline   ZileXa 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 767
  • Joined: 27-May 04

Posted 06 June 2006 - 05:13 PM

I WAS WRONG!

This WORKS:
1
[DefaultUninstall]
ProfileItems = del.shortcuts
RunPostSetupCommands=StartUninstall

[del.shortcuts]
Name   = Copy DVD movies,0x6

[StartUninstall]
SETUP.cmd


2
This one, with a parameter /a for the cmd file, works
It also works without the parameter
[DefaultUninstall]
ProfileItems = del.shortcuts
RunPostSetupCommands=StartUninstall

[del.shortcuts]
Name   = Copy DVD movies,0x6

[StartUninstall]
C:\progra~1\DVD-ReBuilder\SETUP.cmd /a


3
This one also works, wether there is a parameter for CMD file or not.
[DefaultUninstall]
ProfileItems = del.shortcuts
RunPostSetupCommands=StartUninstall

[del.shortcuts]
Name   = Copy DVD movies,0x6

[StartUninstall]
CMD.exe /C C:\progra~1\DVD-Rebuilder\SETUP.cmd /a

playing with quotations "" over the whole line or just the path doesn't matter



4
This does NOT work, parameter for CMD file doesn't make a difference:
[DefaultUninstall]
ProfileItems = del.shortcuts
RunPostSetupCommands=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.

5
This does NOT work either, parameter for CMD file doesn't make a difference:
[DefaultUninstall]
ProfileItems = del.shortcuts
RunPostSetupCommands=StartUninstall

[del.shortcuts]
Name   = Copy DVD movies,0x6

[StartUninstall]
CMD.exe /C %programfiles%\DVD-ReBuilder\SETUP.cmd

tried C:\Program Files..., with "" and without ""... doesn't work!


6
Same for this one, parameter for CMD file doesn't make a difference
[DefaultUninstall]
ProfileItems = del.shortcuts
RunPostSetupCommands=StartUninstall

[del.shortcuts]
Name   = Copy DVD movies,0x6

[StartUninstall]
%programfiles%\DVD-ReBuilder\SETUP.cmd



What 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 :D

This post has been edited by ZileXa: 13 June 2006 - 02:27 PM


#16 User is offline   Delprat 

  • Poll: Why are you reading this ?
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 18-May 05

Posted 07 June 2006 - 03:12 PM

I can't help you, but you didn't tried %16422%. :P

IIUC, you're doing thing in the wrong order.
The INF file is used only to manage the start menu.
The CMD file does all other things.

So why not making the CMD the main script, and call the INF from the CMD ???
Of course, you'll need something to hide the CMD window.

And you really should learn to create InnoSetups : it features a professional look and lots of things you never dreamed about...
(before you ask : yes, i have stock-options :lol: )

#17 User is offline   ZileXa 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 767
  • Joined: 27-May 04

Posted 08 June 2006 - 03:54 AM

Quote

Of course, you'll need something to hide the CMD window.

that's exactly why I decided the INF should run the CMD file :)
Ofcourse I could use HIDE.exe, its only few KB's but it does mean adding another file to the package, don't want to do that.
(I actually have HIDE.exe standardly in my system32 folder, but other people don't).

for installing, I simply let the 7z SFX file call the setup.cmd file and hide the console window.
For uninstalling from Windows Add/Remove Programs, there is no way to call a .cmd or .bat file hidden. So that's why I tried using the INF file.

Thought about INNO (still thinking..) but INNO is all about a Graphical User Interface, I want the most simple installer as possible (as simple as possible for the end-user!).
That means: just double click a file and it installs right away... no Next,Next,Next, Finish.

I will do some research about INNO but I don't think this is possible.
In the mean time I did learn a lot about batchscripting and INF files :)

This post has been edited by ZileXa: 08 June 2006 - 03:55 AM


#18 User is offline   Delprat 

  • Poll: Why are you reading this ?
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 18-May 05

Posted 09 June 2006 - 02:12 AM

View PostZileXa, on Jun 8 2006, 10:54 AM, said:

That means: just double click a file and it installs right away... no Next,Next,Next, Finish.


Quote

Inno Setup FAQ : Is it possible to do a silent install without using the /SILENT or /VERYSILENT command-line parameters?
No, nor is such a feature planned (it would be abused). If it is your intention to keep user interaction to a minimum, use the Disable* [Setup] section directives.


They are :
DisableDirPage = Select Destination Location page (you must set a default dir)
DisableFinishedPage = Setup Completed page (immediately close)
DisableProgramGroupPage = Select Start Menu Folder page (you must set a default start menu folder ; or have no start menu items)
DisableReadyMemo = Ready to Install page (the one which display what will be installed)
DisableReadyPage = Ready to Install page (the second one)
DisableStartupPrompt = This will install... Do you wish to continue? dialog box

Then if you specify no license, no "InfoBefore", no "InfoAfter", no components, no tasks, no languages, you'll get a nearly silent setup. (at least far from "all about a Graphical User Interface")



Another solution is... VBS script ! they are silent by default, and i think they can run a INF or a CMD hidden. (with WshShell.Run "your command here", vbHide). Obviously, the end-user will need WScript installed (a drawback absent if you use inno)

View PostZileXa, on Jun 8 2006, 10:54 AM, said:

That means: just double click a file and it installs right away... no Next,Next,Next, Finish.


Quote

Inno Setup FAQ : Is it possible to do a silent install without using the /SILENT or /VERYSILENT command-line parameters?
No, nor is such a feature planned (it would be abused). If it is your intention to keep user interaction to a minimum, use the Disable* [Setup] section directives.


They are :
DisableDirPage = Select Destination Location page (you must set a default dir)
DisableFinishedPage = Setup Completed page (immediately close)
DisableProgramGroupPage = Select Start Menu Folder page (you must set a default start menu folder ; or have no start menu items)
DisableReadyMemo = Ready to Install page (the one which display what will be installed)
DisableReadyPage = Ready to Install page (the second one)
DisableStartupPrompt = This will install... Do you wish to continue? dialog box

Then if you specify no license, no "InfoBefore", no "InfoAfter", no components, no tasks, no languages, you'll get a nearly silent setup. (at least far from "all about a Graphical User Interface")



Another solution is... VBS script ! they are silent by default, and i think they can run a INF or a CMD hidden. (with WshShell.Run "your command here", vbHide). Obviously, the end-user will need WScript installed (a drawback absent if you use inno)

This post has been edited by Delprat: 09 June 2006 - 02:13 AM


#19 User is online   ricktendo 

  • Group: Banned Members
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,228
  • Joined: 06-June 06
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 14 August 2007 - 10:15 PM

OK I know this is an old post but just for the purposes of documentation and getting this on the record this worked for me in my addon

[DefaultInstall]
AddReg = RunOnce.AddReg

[RunOnce.AddReg]
HKLM,"%RUNONCE%","CapOCR",0,"RUNDLL32 advpack.dll,LaunchINFSection CapOCR.inf,Cap.Install"

[Cap.Install]
RunPostSetupCommands = Cap.Setup

[Cap.Setup]
CMD /Q /C CD """%16422%\%USD%""" & CapSetup.bat

[Strings]
USD = "Utilities\USDownloader"

This post has been edited by ricktendo64: 14 August 2007 - 10:16 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy