Jump to content

How to unattendedly right click and install?


NOTS3W

Recommended Posts

I have a program that to manually install requires right-clicking on setup.inf and choosing Install from the popup context menu. It requires no other options or switches, it just installs and asks to reboot to finish. How do I do that in an unattended installation? I don't see how to make that happen on a command line and I don't know what to give an addon maker as the command to execute.

Here is the program and here is what I'm trying to automate. It adds the Security tab to the file and folders Properties in XP Home.

I've looked at other addons and switchless installers and they all seem to have an exe, bat or cmd to kick them off.

Any help?

Thanks.

Ray

Link to comment
Share on other sites


Hi Ray :)

rundll32 setupapi,InstallHinfSection DefaultInstall 128 filename.inf

Exchange 'filename.inf' with correct filename. If a reboot is neccesary, then it will be supressed. If you want to reboot automatically, if needed, then change '128', to '131'.

CU, Martin.

Link to comment
Share on other sites

Hmm, interesting. Here are two others I found once.. the first one is probably the 16-bit equivalent of yours, and the second looks less versatile, as I don't know if/where you can add the numerical code. Do you know of any documentation on said codes?

rundll setupx.dll,InstallHinfSection DefaultInstall 128 filename.inf

rundll32 advpack.dll,LaunchINFSection filename.inf, DefaultInstall

Edit: nevermind, I found it: http://msdn2.microsoft.com/En-US/library/aa376957.aspx

Edited by Ver Greeneyes
Link to comment
Share on other sites

Martin, my friend, you seem to have all the answers. At least to my questions. :thumbup

Help me understand what this does, though. I assume that you somehow know to run RUNDLL32 and have it execute what's in the INSTALLHINFSECTION portion of SETUPAPI(.DLL?), right? I'll take that much as a given, but I have no idea how you determined to do that. Did you decide to use that because of something about setup.inf or is this just a generic way to install an inf?

Are DEFAULTINSTALL and 128 parameters you are passing to rundll32 or are they specific to setup.inf?

Then, of course, there's SETUP.INF which is the file I need to install. I can see a DefaultInstall label inside of setup.inf, so I'm guessing your command is telling runndll32 setupapi to execute the defaultinstall portion (and ONLY that portion?) of setup.inf.

Does this need to be included in some kind of installer? The Microsoft exe file contains eight files and a folder, at least some of which is needed to complete the installation. I'm thinking I can make an addon including all of those files and tell Addon Maker to execute your command line. I'll have to try that this evening. Otherwise, I'm not sure what to do with all of the files that go along with setup.inf.

You are certainly a wealth of information, Martin. Thanks for your help once again.

Ray

BTW, when I install this manually, I get an error message that unknown versions of files are present but before I can respond to that, I get another message asking to reboot the system for the change to take effect. Rebooting clears the error message and it doesn't return later. I'm sure the file error is due to the fact that these are not XP Home files and that I'm using them in a bastardized way. Is there a way to suppress or cancel that message so I can continue my unattended installation? Because it needs to be followed by a reboot, I assume it should be run from cmdlines at T-12. I can experiment with that, but if the same error shows up I expect it will interrupt my installation.

Link to comment
Share on other sites

Rut roh. That didn't work. I can run it from a command prompt, can't I? I was experimenting to see which files it really needs. I placed all of the program's files in a folder on my desktop and wrote a one-line cmd file containing only the line posted above (with the last filename.inf replaced by SETUP.INF). It's in the same folder so paths shouldn't be a problem.The command prompt opens, the command is issued, and all I get is the very informative message "Installation failed." I even tried with a full path to setup.inf.

I guess this wasn't as obvious as I thought. :blushing:

Ray

Link to comment
Share on other sites

I am very sorry, Ray - I must confess that i don't know what the problem is and also i'm no inf file expert at all, but just knew the generic command line needed for installing inf files from a batch file :(

The line is a standard line used to run any type of inf file. You can see a short description here for the different parameters of rundll32 :

http://www.dx21.com/SCRIPTING/RUNDLL32/INF.ASP

Sorry again, mate - Now i will step off and let someone else and much more knowledgeble lead you in the right direction; ricktendo64 :)

Link to comment
Share on other sites

Got it! "You must include 128 to set the default path of the installation to the location of the INF, otherwise a system-provided INF is assumed." (from the page Martin referred to.)

@Martin: No problem and thanks for setting me in the right direction.

After reading the article mentioned by Ver Greeneyes, I had a better idea of what I was looking for and found several other threads here all referring to the rundll32 setupapi method. They usually include a path in front of the setup.inf file. I assumed that if I ran that command from within the folder that contains setup.inf that it would work without requiring a path (that Windows would look in the current folder before checking in the system path). Only when I provide a complete path to setup.inf, even if rundll32 is in the same folder, does this work.

As a bonus, it appears that it suppresses the invalid files error message that shows up when I right-click and install.

@Ricktendo64: I tried placing the setup.inf file in the Windows\inf folder, but that didn't work, probably because the other files it looks for weren't there.

Here are the files I extracted from SCESP4I.exe:

 Directory of C:\TestInf
05/31/2007 07:18 AM <DIR> .
05/31/2007 07:18 AM <DIR> ..
07/16/1998 02:15 PM 1,215,720 immc.exe
10/15/1998 11:04 AM 734,517 mssce.cab
10/15/1998 11:04 AM 222,976 mssce.exe
10/15/1998 11:04 AM 11,830 readme.txt
10/15/1998 11:04 AM 37,136 regsvr32.exe
10/15/1998 11:04 AM 1,462 scefiles.inf
10/15/1998 11:04 AM 267 scesetup.inf
10/15/1998 11:04 AM 8,219 setup.inf
05/31/2007 07:18 AM <DIR> symbols

I doubt that all of those files are really required, but I don't know how to tell which are and which aren't. Evidently, I need to extract the archive into a folder and include the path to that folder in the rundll32 command regardless of where rundll32 is executed from:

rundll32 setupapi,InstallHinfSection DefaultInstall 128 C:\testinf\setup.inf

That works! I'll use system variables in the path when I actually do this.

The two remaining questions are, what needs to be included in the folder and barring that, how to I extract the exe archive THEN run setup? Here's what setup looks like:

[Version]
Signature="$Windows NT$"
AdvancedINF=2.5
ExtensionGUID = {d0e72d64-e6ab-11d1-9362-00c04fd92f7b}
Title=%SCETITLE%
LayoutFile=SCEFILES.INF

; Main
[AppInstall]
RegCheck = HKLM,Software\Microsoft\Windows NT\CurrentVersion,,CurrentVersion,>=4.0,%WrongNTVersion%
RegCheck = HKLM,Software\Microsoft\Windows NT\CurrentVersion,,CSDVersion,>=Service Pack 4,%WrongNTServicePack%
UserCheck = ,Administrators,%LogonAsAdmin%
Switch = C,%InstallCmdLineHelp%,\ ;Help for this switch
MFCCheck, \ ;Check for MFC42U.DLL
InstallCmdLine,\ ;Command Line install
CmdLineCheckInstall,\ ;Make sure installion succeded.
SecureDirectory,\ ;Secure our directory.
PostSecureDirectory,\ ;Delete SCP path item
DefFinish ;Display message to user

Switch = ,%DefaultInstallHelp%,\ ;Help for this switch.
MFCCheck,\ ;Check for MFC42U.DLL
CheckForIE,\ ;Checks to make sure IE was installed
DefPromptUser,\ ;Prompt user with install message.
CheckMMCVer,\ ;Install MMC
DefaultInstall,\ ;Copy SCE files and register the DLLS
CmdLineCheckInstall,\
DefCheckInstallation,\ ;Make sure registration completed successfuly
CheckForMMC,\ ;Makes sure MMC was installed
SecureDirectory,\ ;Secure our directory.
PostSecureDirectory,\ ;Delete SCP path item
DefFinish ;Tell the user we finished successfuly

;Alpha check the version of MFC42U.DLL
[MFCCheck.NTAlpha]
; Reverse version check.
FileCheck = %11%\MFC42U.DLL,==4.21.0.7022,%IncompatibleFileVersion%,FC_VERTRUE_END

; Install command line only
[InstallCmdLine]
PreInstallPrompt = %InstallQuestionCmd%
FileCheck = %11%\WLDAP32.DLL,>=5.0,%FileNotFound%
CopyFiles = CmdLineCopy,InfCopy,SceTemplatesCopy,AcluiHelpCopy
Addreg = MMCReg
PostRunApp = PostSetupCmdSection

; Make sure command line was installed correctly.
[CmdLineCheckInstall]
RegCheck = HKLM,Software\Microsoft\Windows Nt\CurrentVersion\Secedit,,,,%SetupNotComplete%
FileCheck =%11%\SceDLL.dll,,%SetupNotCompleteFile%
FileCheck =%11%\secedit.exe,,%SetupNotCompleteFile%

; Check for the version of the MMC file, if it's later then do nothing.
[CheckMMCVer]
FileCheck =if( %11%\MMC.EXE,>5.00.1713.1 ) == SETUP_NORMAL,END,RUN(InstallMMCOnly)

; Prompt user to install MMC.
[InstallMMCOnly]
InstallPrompt = %InstallMMCQ%,,MB_YESNOCANCEL|MB_ICONQUESTION
InstallPrompt = %InstallMMCWarn%,,MB_OK|MB_ICONEXCLMATION
PostRunApp = RunMMC

;Make sure IE is installed.
[CheckForIE]
FileCheck = %11%\WLDAP32.DLL,,%WrongIEVersion%
FileCheck = %11%\SHLWAPI.DLL,,%WrongIEVersion%
FileCheck = %11%\URLMON.DLL,,%WrongIEVersion%
FileCheck = %11%\WININET.DLL,,%WrongIEVersion%

;Default installation prompt
[DefPromptUser]
PreInstallPrompt = %InstallQuestionDef%

;Make sure MMC was installed.
[CheckForMMC]
RegCheck = HKLM,Software\Microsoft\MMC,,,,%MMCNotInstalled%

; i386 Install everything
[b][DefaultInstall]
CopyFiles = CmdLineCopy, SceTemplatesCopy, WinSysCopy, InfCopy, ,AcluiHelpCopy
RegisterDll = RegisterDLLSection
Addreg = MMCReg[/b]

; Alpha install.
;[DefaultInstall.NTAlpha]
; CopyFiles = CmdLineCopyNTAlpha, SceTemplatesCopy, WinSysCopy, InfCopy, ,AcluiHelpCopy
; RegisterDll = RegisterDLLSection
; Addreg = MMCReg

;Make sure our reg key exists.
[DefCheckInstallation]
RegCheck = HKLM,Software\Microsoft\MMC\SnapIns\{803E14A0-B4FB-11D0-A0D0-00A0C90F574B},,,,%SetupNotCompleteMMC%

; Success ful message
[DefFinish]
PostInstallPrompt = %FinishMessage%

; Directory Creation area, and where to copy.
[DestinationDirs]
; SCE stuff.
SceDirCopy=25, Security
SceTemplatesCopy = 25, Security\Templates
WinSysCopy=11,
CmdLineCopy=11
InfCopy=25, Inf
AclUiHelpCopy=25,help


; Install MMC
[RunMMC.NTx86]
IMMC.EXE

[RunMMC.NTAlpha]
AMMC.EXE

; Secure out directoies and registry keys.
[PostSecureDirectory]
DelReg = DelRegSecEdit
PostRunApp = DeleteSetupSAD

[SecureDirectory]
FileCheck = %11%\scedll.dll,,%FileNotFound%
FileCheck = %11%\secedit.exe,,%FileNotFound%
PostRunApp = RunSecureDirectory

[RunSecureDirectory]
secedit.exe /configure /areas FILESTORE REGKEYS /cfg .\scesetup.inf /db %25%\security\database\scesetup.sdb /overwrite

[DeleteSetupSAD]
del /F /Q %25%\security\database\scesetup.sdb

[RegisterDLLSection]
%11%\Scedll.dll
%11%\wsecedit.dll

; If the register section didn't work, then we'll do this instead.
[PostSetupCmdSection]
regsvr32.exe %11%\scedll.dll /s
regsvr32.exe %11%\wsecedit.dll /s

[MMCPostSetupCmdSection]
regsvr32.exe %11%\mmcndmgr.dll /s
regsvr32.exe %11%\hhctrl.ocx /s
regsvr32.exe %11%\itss.dll /s
regsvr32.exe %11%\itircl.dll /s

; BEGIN Register section
[MMCreg]
HKCR,.msc,,2,mscfile
HKCR,mscfile\shell\open\command,,,"%11%\MMC.EXE ""%%1"""
HKCR,Clsid\%CLSID_RSHX_NTFS%,,,%DESCRIPTION%
HKCR,Clsid\%CLSID_RSHX_NTFS%\InProcServer32,,,%MODULENAME%
HKCR,Clsid\%CLSID_RSHX_NTFS%\InProcServer32,"ThreadingModel",,Apartment
HKCR,*\%SHEXPS%\%CLSID_RSHX_NTFS%,,,
HKCR,Drive\%SHEXPS%\%CLSID_RSHX_NTFS%,,,
HKCR,Directory\%SHEXPS%\%CLSID_RSHX_NTFS%,,,
HKCR,Clsid\%CLSID_BRIEFCASE%\%SHEXPS%\%CLSID_RSHX_NTFS%,,,

[DelRegSecEdit]
HKLM,Software\Microsoft\Windows Nt\CurrentVersion\Secedit,DefaultProfile
HKLM,Software\Microsoft\Windows Nt\CurrentVersion\Secedit,TemplateUsed
; END Registr section

; BEGIN Copy Files sections
; Template files to %windir%\security\templates
[AclUiHelpCopy]
Aclui.hlp,,,32
[SceTemplatesCopy]
securws4.inf,,,32
securdc4.inf,,,32
basicwk4.inf,,,32
basicsv4.inf,,,32
basicdc4.inf,,,32
compws4.inf,,,32
compdc4.inf,,,32
hisecws4.inf,,,32
hisecdc4.inf,,,32
off97sr1.inf,,,32

; Win sys copy to %windir%\system32
[CmdLineCopy]
; Sec edit.
SeCEdit.exe,,,32
scedll.dll,,,32
Aclui.dll,,,32
Rshx32_5.dll,,,32
; Jet enjine
esent.dll,,,32
esentprf.dll,,,32
esentutl.exe,,,32
; ACL editor dlls.

[CmdLineCopyNTAlpha]
; Sec edit.
SeCEdit.exe,,,32
scedll.dll,,,32
; ACL editor dlls.
Aclui.dll,,,32
Rshx32_5.dll,,,32
; Jet enjine
esent.dll,,,32
esentprf.dll,,,32
esentutl.exe,,,32
mfc42u.dll,,,32

[WinSysCopy]
; Secedit Executables.
wsecedit.dll,,,32

[InfCopy]
SCEregvl.inf,,,32

; String declartions
[Strings]
WrongNTVersion="You must install Microsoft Windows NT 4.0 or greater."
WrongNTServicePack="You must install Microsoft Windows NT 4.0 Service Pack 4."
WrongIEVersion="You must install Microsoft Internet Explorer 3.0 or greater."
LogonAsAdmin="You must be logged on as adminitrator."
SCETITLE="Microsoft Windows NT Security Configuration Manager"
DISKTITLE="Microsoft Windows NT Service Pack 4 CD"
FinishMessage="Setup completed successfully."
InstallCmdLineHelp="Install command line tools only."
InstallMMCOnlyHelp="Install MMC only."
MMCNotInstalled="You must install Microsoft Management."
DefaultInstallHelp="Default installation installs the UI and command line tools."
MODULENAME=rshx32_5.dll
DESCRIPTION=Security Shell Extension
SHEXPS=shellex\PropertySheetHandlers
InstallQuestionDef="Install Microsoft Windows NT Security Configuration Editor - Full install?"
InstallQuestionCmd="Install Microsoft Windows NT Security Configuration Editor - Command line tool only?"
CLSID_RSHX_NTFS={1f2e5c40-9550-11ce-99d2-00aa006e086c}
CLSID_BRIEFCASE={85BBD920-42A0-1069-A2E4-08002B30309D}
InstallMMCQ="Would you like to Install Microsoft Management Console?"
InstallMMCWarn="This portion of setup may request that you reboot your computer. Please reboot the computer and run setup again if you are asked to do so."
SetupNotCompleteFile="MSSCE did not complete successfully. File '%0' not found."
SetupNotComplete="Setup did not complete successfully! Please run setup again"
SetupNotCompleteMMC="Microsoft Management console was not found. Please run setup again and install Microsoft Manage Console."
IncompatibleFileVersion="'%0' is incompatible with Security Configuration Editor. Please install a compatible version before installing Security Configuration Editor. Setup aborting"

Can anyone tell from that which files from the archive are actually required?

If not, I can copy the archive into a folder during unattended install and have cmdlines extract it before using the rundll command (then delete the folder). Or is there a way to include all of this in an installer or addon so that rundll32 finds setup.inf and any of the other files it needs?

Thanks for the very good information. I learn something new here everyday.

Ray

Link to comment
Share on other sites

Here's an interesting complication. Does anyone know how to deal with this?

The setup.inf file that rundll32 references is located INSIDE of the self extracting archive SCESP4I.exe. Since no one seems to know which of the files in that archive are truly necessary, I'll just copy the entire archive to the C drive, extract it and use the rundll32 command (above). Of course, it's not that easy.

When I execute SCESP4I.exe, the extractor prompts for the destination folder. I can't find a way to make that silent and just use the default (current) folder. If I manually right-click the file and use 7-Zip to Extract Here, it works silently. SCESP4I.exe is a Microsoft downloaded file. Does anyone know of a way to extract its contents silently? I've already tried combinations of /s, /q, /silent, /quiet, even typing a full path behind the file name, all to no avail.

My work around is to extract the files and re-archive them into a self-extracting 7-Zip file and include that in my unattended file set. That works, but I'd prefer to just use the Microsoft file without repackaging it. Any ideas?

Thanks.

Ray

Link to comment
Share on other sites

  • 2 weeks later...

This is a very interesting thread.

See, I want to do something similar... er, but different. :D

I have a Technician Toolkit CD that I make for myself. In it, I include all the drivers I use most: ATi, nvidia, Realtek, etc..) and I want to slim it down a little. I've already turned the driver installation programs into 7zip SFX's, which DID save alot of space (man, InstallShield sucks!!). But I want to take it one step further.

Since I rarely need anything other than the XP drivers, I was gonna use a driver backup program to back it up (once installed on my system). This should be the XP driver ONLY. Then 7zip it.

But.. I need to call up the INF file... on a CD. What should I use for the PATH?! Is there something I can use, similar to %24% or %SystemRoot%, except that it's the root path of the CD (no matter what drive I stick it in)??

:wacko:

[EDIT]

PS: It doesn't need to be service-pack compliant. I don't plan to use this as an addon. ;)

Edited by RaGhul
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...