Jump to content

Plamdi

Member
  • Posts

    82
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Australia

Everything posted by Plamdi

  1. Final Version. You may download it, extract it and use it to your will. Source code is fully commented. Features: The ability to automate nearly any installation. Excellent error-handling. Program can detect if the installation has abnormally terminated and quit early if necessary. Configuration file may be compressed with makecab for that professional touch. Benefits: Open-source, freeware. Universal - configuration file can hold as many programs and commands as needed. Simple configuration, and command-line usage. The Bottom Line: It's a script that I wrote over 3 days. Many other people have used VBS on this forum to automate installations for single programs only - this can be used for all those programs. Many forum members also wrote linear code which doesn't allow for the program to accurately wait for a dialogue window to appear - which is what oem installer is capable of. Download now, and enjoy. Do not use the code posted in the previous post as it's out of date (however it has no errors in it so I feel free leaving it up). oeminstaller.rar
  2. For anyone who's interested I re-installed an OEM copy of Windows XP Home for a family member last night, using nothing but the original reinstallation CD that came with the PC (and a custom unattend.txt file). I used Dell's "master CD key" found on the CD itself in i386\WINNT.SIF. No product activation was required. I had not copied over any other files, such as with the "backup" or "oembios" methods here: http://unattended.msfn.org/unattended.xp/view/web/29/ I had the files ready to be manually copied over, but they weren't needed! This was confirmed by typing "oobe/msoobe /a" to bring up a diolauge reporting that Windows was already activated.
  3. There were three small bugs in my previous code, here is the bug-free code. Option Explicit On Error Resume Next If Wscript.Arguments.Count<>1 Then WScript.Quit(0) Dim WshShell,i,j,ini,fso,f,s,s_,p,m1,m2,t,inst(),pCheck,pNames() Dim objWMIService,objProcess,colProcess,ProgName,ProgFlags Set WshShell=WScript.CreateObject("WScript.Shell") Set fso=CreateObject("Scripting.FileSystemObject") Set objWMIService=GetObject("winmgmts:" _ &"{impersonationLevel=impersonate}!\\.\root\cimv2") ini=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)+_ InStrRev(WScript.ScriptName,".")-Len(WScript.ScriptName))&"INI" p=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-_ Len(WScript.ScriptName)) ProgFlags="":pCheck=False If Not fso.fileexists(ini) Then Set WshShell=Nothing:WScript.Quit(0) Set f=fso.OpenTextFile(ini,1) s=VbCrLf&f.ReadAll&VbCrLf&VbCrLf f.Close t=VbCrLf&"["&UCase(Wscript.Arguments(0))&"]" m1=InStr(UCase(s),t)+Len(t) If m1=0 Then Set WshShell=Nothing:WScript.Quit(0) m2=InStr(m1+3,s,VbCrLf&"[") If m2=0 Then m2=Len(s) s=Mid(s,m1,m2-m1)&VbCrLf s_=Ucase(s) m1=InStr(s_,VbCrLf&"PROGRAM") If m1=0 Then Set WshShell=Nothing:WScript.Quit(0) m1=InStr(m1+3,s,"=")+1 If m1=0 Then Set WshShell=Nothing:WScript.Quit(0) m2=InStr(m1,s,VbCrLf) ProgName=Mid(s,m1,m2-m1) If Left(ProgName,2)="@\" Then ProgName=p&Right(ProgName,Len(ProgName)-2) If Not fso.fileexists(ProgName) Then Set WshShell=Nothing:WScript.Quit(0) Set fso=Nothing m1=InStr(s_,VbCrLf&"SWITCHES") If m1<>0 Then m1=InStr(m1+3,s,"=")+1 If m1<>0 Then m2=InStr(m1,s,VbCrLf) ProgFlags=" "&Mid(s,m1,m2-m1) End If End If m1=1:i=-2:m2=0 Do m2=InStr(m2+1,s_,VbCrLf&"PROCESSCHECK") If m2=0 Then m1=0 i=i+1 Loop While m1 If i<>-1 Then j=i:pCheck=True ReDim pNames(i) m1=1:m2=1 For i=0 To j m1=InStr(m1,s_,VbCrLf&"PROCESSCHECK") m1=InStr(m1+3,s,"=")+1 If m1=0 Then Set WshShell=Nothing:WScript.Quit(0) t=InStr(m1+3,s,VbCrLf)+1 pNames(i)=Mid(s,m1,t-m1-1) Next'i End If m1=1:i=-2:m2=0 Do m2=InStr(m2+1,s_,VbCrLf&"OPERATIONTITLE") If m2=0 Then m1=0 i=i+1 Loop While m1 m1=1:j=-2:m2=0 Do m2=InStr(m2+1,s_,VbCrLf&"OPERATIONKEYS") If m2=0 Then m1=0 j=j+1 Loop While m1 If i<0 OR i<>j Then Set WshShell=Nothing:WScript.Quit(0) ReDim inst(i,1) m1=1:m2=1 For i=0 To j m1=InStr(m1,s_,VbCrLf&"OPERATIONTITLE") m1=InStr(m1+3,s,"=")+1 If m1=0 Then Set WshShell=Nothing:WScript.Quit(0) t=InStr(m1+3,s,VbCrLf)+1 inst(i,0)=Mid(s,m1,t-m1-1) m2=InStr(m2,s_,VbCrLf&"OPERATIONKEYS") m2=InStr(m2+3,s,"=")+1 If m2=0 Then Set WshShell=Nothing:WScript.Quit(0) t=InStr(m2,s,VbCrLf)+1 inst(i,1)=Mid(s,m2,t-m2-1) Next'i j=0:s="":s_="" WshShell.Run(""""&ProgName&""""&ProgFlags) For i=0 To UBound(inst) If inst(i,1)="[!]" Then Set colProcess=Nothing Set colProcess=objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = """&inst(i,0)&"""") For Each objProcess in colProcess objProcess.Terminate() Next Else Do until WshShell.AppActivate(inst(i,0)) WScript.Sleep 300 If pCheck Then If CheckForProcess() Then j=0 Else j=j+1 If j=14 Then Set WshShell=Nothing:WScript.Quit(1) End If End If Loop WshShell.SendKeys inst(i,1) End If Next'i Set WshShell=Nothing WScript.Quit(1) Function CheckForProcess() CheckForProcess=False For Each t in pNames Set colProcess=Nothing Set colProcess=objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = """&t&"""") For Each objProcess in colProcess CheckForProcess=True Exit Function Next Next End Function Save as OEMINST.VBS [Winamp] Program =@\WINA295.EXE Switches =/S ProcessCheck01 =WINA295.EXE ProcessCheck02 =WINAMP.EXE OperationTitle01 =Winamp Setup: Settings OperationKeys01 ={TAB}{TAB}N{TAB} {UP} {UP}{UP}{UP} ~ OperationTitle02 =Winamp Setup: Winamp successfully installed OperationKeys02 =%{F4} Save as OEMINST.INI The ability to terminate processes has been added, syntax is: OperationTitle=notepad.exe OperationKeys=[!] That would be suitable for killing notepad if that's launched at the end of installation (keep in mind EVERY instance of notepad running will be ended). Commented source code and documentation will come next. Enjoy. Note: Some dialogues don't actually get focus when WshShell.AppActivate is run. To test any automated installation always alt-tab to give another application focus as soon as you've run oeminstaller. This is not an error in OEM Installer, but rather a limitation of WScript. If the automation fails then do this: [CloneDVD] Program =@\SetupCloneDVD2Slysoft.exe Switches =/S ProcessCheck =SetupCloneDVD2Slysoft.exe OperationTitle =CloneDVD2 Setup OperationKeys =N (OLD) For some reason WshShell.AppActivate("CloneDVD2 Setup") will return true, but not pass focus on to the dialogue. You can test this. [CloneDVD] Program =@\SetupCloneDVD2Slysoft.exe Switches =/S ProcessCheck =SetupCloneDVD2Slysoft.exe OperationTitle01 =CloneDVD2 Setup OperationKeys01 =%{TAB} OperationTitle02 =SetupCloneDVD2Slysoft.exe OperationKeys02 =[!] (NEW) This will cause OEM Installer to wait until the final dialogue is displayed, hit Alt-Tab (a non-invasive command, you can put whatever you like) - and then terminate the SetupCloneDVD2Slysoft.exe process.
  4. I'm guessing you could uninstall office and try it.
  5. Thanks, I'm in my element with VBScript, it has become my favourite programming language - and it's far more powerful then most people realize. Here's an updated version: See post below The code will now check (optional) running processes for processes specified in the ini file. Winamp is still an excellent example for this, because first the setup will launch (winamp295.exe), and then winamp.exe will launch (which is actually what is running when we automate the dialogues). So.... the ini file could look like this: See post below If neither of the processes is found running then the timeout will begin. This lasts 4-5 seconds before terminating the script. This is to allow for transitional time while neither process is running. The only other feature I intend to add is the ability to terminate a process without using keystrokes. This will be useful because it means that if an installation runs the installed program immediately, then OEM Installer can kill the process before it even has time to fully load. I'm thinking the syntax for this would be: OperationTitle02 =winamp.exe OperationKeys02 =[!] Which could replace: OperationTitle02 =Winamp Setup: Winamp successfully installed OperationKeys02 =%{F4} I chose "[!]" since it would be invalid syntax for sending keystrokes. Of course you probably wouldn't want to use it in this instance with Winamp since you want to give it time to set up the icons and register it's registry settings ... but if it was about to start winamp.exe (instead of already being started) it'd be real handy. Anyhow, work calls... will report in later...
  6. This is a VBS program I just wrote, I'd like to get some feedback first. The idea is that for programs that refuse to install without user interaction this program can step in and automate the process. It's not perfect, but it does the job. See post below Save as oeminst.vbs See post below Save as oeminst.ini You can add as many programs as you like to the .ini, just make sure they're all under their own title in square brackets. You cannot use white space right of the "=", or it will be considered to be part of your expression. OperationTitleXXX and OperationKeysXXX run in chronological order, not necessarily in numerical (or alphabetical) order. "@\" at the start of the program name indicates to use the path to the actual vbs file. otherwise specify a complete path, Example: Program=C:\INSTALL\WINAMP295.EXE Do not use quotations around any of the expressions, they are not needed. The "Switches" option is optional, you do not have to use switches with your program for it to work. To use the example I gave you (Winamp 2.95) download WINAMP295.EXE from: http://www.oldversion.com/program.php?n=winamp Save in the same directory as OEMINST.VBS and OEMINST.INI, and type: WSCRIPT OEMINST.VBS WINAMP From the command prompt. Edit: A quick explination... Winamp installation runs and then displays a window titled "Winamp Setup: Settings" and waits for user input. OEM Installer jumps in, changes some values, for instance "How should Winamp connect to the Internet?" is set to "No internet connection available" to prevent the dialogue box that would pop-up after this step, and some checkboxes are changed. Then it hits Enter and on the next dialogue box, entitled "Winamp Setup: Winamp successfully installed", OEM Installer hits Alt-F4 rather than Enter to prevent Winamp running. This script has excellent Error handling, and will be even more fool proof once I've added the ability to detect if the installation program has unexpectedly ended early and terminate early accordingly. For any other program use the same format in the ini file, and then type: WSCRIPT OEMINST.VBS PROGRAMNAME From the command prompt, where PROGRAMNAME is the name appearing in the square brackets to identify the program you want to install. I'll write some more coherent documentation later. If there are any bugs, or improvements you want to see let me know so I can improve it. It's 95% complete as is right now.
×
×
  • Create New...