Incroyable HULK Posted April 10, 2005 Share Posted April 10, 2005 I am wondering if it is an "easy" process to convert this batch file to a vb script:FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\CD.bin SET CDROM=%%i:if not exist %windir%\system32\reg.exe copy "%CDROM%\CD\W2K\reg.exe" %windir%\system32SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %KEY% /V TITLE /D "Test" /fREG ADD %KEY%\001 /VE /D "MS Office Pro 2003 Fr." /fREG ADD %KEY%\001 /V 1 /D "\\Source\setup.exe TRANSFORMS=Unattended.mst /qb-" /frundll32.exe iernonce.dll,RunOnceExProcessAny input appreciated! Link to comment Share on other sites More sharing options...
RogueSpear Posted April 10, 2005 Share Posted April 10, 2005 It's quite easy. I'll post one of my scripts that has those elements in it for you to look at. This is the VBscript I run from cmdlines.txt:Option ExplicitDim ws, fs, sysdrv, windir, progdir, Drives, Drive, strCD, strOEMSet ws = WScript.CreateObject("WScript.Shell")Set fs = CreateObject("Scripting.FileSystemObject")sysdrv = ws.ExpandEnvironmentStrings ("%SYSTEMDRIVE%")windir = ws.ExpandEnvironmentStrings ("%SYSTEMROOT%")progdir = ws.ExpandEnvironmentStrings ("%PROGRAMFILES%")Drives = Array("C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", _ "T", "U", "V", "W", "X", "Y", "Z")For Each Drive In Drives If fs.FileExists(Drive & ":\WIN51") Then strCD = Drive & ":\"NextstrOEM = strCD & "OEM\"'**********************************************************************'** Subroutine; Set the RunOnceEx key with values **'**********************************************************************Sub SetROE Dim strKeyPath strKeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" ws.RegWrite strKeyPath & "TITLE", "Installing Software", "REG_SZ" ws.RegWrite strKeyPath & "001\", "Cleaning up" , "REG_SZ" ws.RegWrite strKeyPath & "001\1", strOEM & "001_Start.vbs", "REG_SZ" If fs.FileExists(strOEM & "Streets.7z") Then ws.RegWrite strKeyPath & "005\", "Microsoft Streets and Trips 2005", "REG_SZ" ws.RegWrite strKeyPath & "005\1", strOEM & "005_Streets.vbs", "REG_SZ" End If If fs.FileExists(strOEM & "Microsoft Office 2003 SP1\PRO11.MSI") Then ws.RegWrite strKeyPath & "010\", "Microsoft Office 2003 SP1", "REG_SZ" ws.RegWrite strKeyPath & "010\1", strOEM & "010_Office.vbs", "REG_SZ" End If ws.RegWrite strKeyPath & "015\", "Administrative Tools and Advanced Applications", "REG_SZ" ws.RegWrite strKeyPath & "015\1", strOEM & "015_Admin.vbs", "REG_SZ" ws.RegWrite strKeyPath & "020\", "Accessories and Multimedia Applications", "REG_SZ" ws.RegWrite strKeyPath & "020\1", strOEM & "020_Accessories.vbs", "REG_SZ" ws.RegWrite strKeyPath & "025\", "Utilities and CD-R Tools", "REG_SZ" ws.RegWrite strKeyPath & "025\1", strOEM & "025_Utilities.vbs", "REG_SZ" ws.RegWrite strKeyPath & "030\", "Security and Malware Applications", "REG_SZ" ws.RegWrite strKeyPath & "030\1", strOEM & "030_Security.vbs", "REG_SZ" ws.RegWrite strKeyPath & "050\", "Compress Select Directories", "REG_SZ" ws.RegWrite strKeyPath & "050\1", strOEM & "050_Compress.vbs", "REG_SZ" 'ws.RegWrite strKeyPath & "055\", "Initial Hard Disk Defragmentation", "REG_SZ" 'ws.RegWrite strKeyPath & "055\1", strOEM & "055_1stDefrag.vbs", "REG_SZ" ws.RegWrite strKeyPath & "060\", "Configure the Page File", "REG_SZ" ws.RegWrite strKeyPath & "060\1", strOEM & "060_PageFile.vbs", "REG_SZ" ws.RegWrite strKeyPath & "065\", "Defragment the Registry", "REG_SZ" ws.RegWrite strKeyPath & "065\1", strOEM & "065_RegDefrag.vbs", "REG_SZ"End Sub'**********************************************************************'** Run Tasks **'**********************************************************************If fs.FileExists(sysdrv & "\Drivers.cmd") Then fs.DeleteFile(sysdrv & "\Drivers.cmd"), Truews.Run "REGEDIT /S cmdlines.reg",0,TrueSetROEEDIT: Well for some reason the comment lines got garbled. Also if you copy/paste this into notepad on a 1024x768 screen it should be much more readable. Link to comment Share on other sites More sharing options...
Incroyable HULK Posted April 12, 2005 Author Share Posted April 12, 2005 Thanks you for your reply, but all your example are pointing to another external file... is it possible to do something like this:ws.RegWrite strKeyPath & "TITLE", "Installing Software", "REG_SZ"ws.RegWrite strKeyPath & "001\", "MS Office Pro 2003", "REG_SZ"ws.RegWrite strKeyPath & "001\1", "\\Source\setup.exe TRANSFORMS=Unattended.mst /qb-", "REG_SZ" Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 12, 2005 Share Posted April 12, 2005 I Believe This Set The Source , Here Is I Hope A Correct Break Down It say A Drive With This File WIN51 = strOEMThen He Add Another Varible OEM\ To it For The PathIf fs.FileExists(Drive & ":\WIN51") Then strCD = Drive & ":\"Next strOEM =strCD & "OEM\"ws.RegWrite strKeyPath & "065\1", strOEM & "065_RegDefrag.vbs", "REG_SZ" Link to comment Share on other sites More sharing options...
RogueSpear Posted April 12, 2005 Share Posted April 12, 2005 Yes, I populate my RunOnceEx with a series of individual VBscripts (hey I like it what can I say). But you could point at an executable file just as easily. 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