Jump to content

Menu to run with RunOnceEx to customise install


Recommended Posts

ok...what i want to do is to make a Menu (using batch or vbs maybe?) that will run the first time you get into windows, which will give you different options about what software to install...

i want to be able to use the same disk on 2 (or more) computers, however, one has a LG burner, the other has Pioneer, and the bundled software will only work with the specific drive...and i want Bitcomet installed on one PC, but not the other, etc, etc...

anyone have a way to do it???

doesn't have to be flash...i remember u used to have a menu system as my PC was booting up, which was in the Autoexec.bat and config.sys times...ie,

1.Dos

2.Win95

3.Dos wo/CD Rom

4.Norton Commander

and you just pressed the approtraite number...now, that was some time ago, and have long lost the actual files...

anyone have an easy way to do it??

Link to comment
Share on other sites


Here is a VBS script that checks for the CD PNP ID

Blue Text Array Names

1:\ It has a array for the PNP ID check

The Array Name : CheckCD

It has 2 ID in there one is mine and the other is some one elses.

Add yours To It.

2:\ It has 2 other arrays for app to install. I use | this to separate

Example

TweakUi|exe|/passive /qr = TweakUi.exe /passive /qr

The script then check the first array, if true it checks either of these array

Array Name 1 : Computer1

Array Name 2 : Computer2

3:\ It the breaks either Computer1 or Computer2 into new arrays

Array Name : App

4:\ It then Uses the information to start a search for the app

Saves As WHAT_EVER_YOU_WANT.vbs

  Const ForReading = 1, ForWriting = 2,ForAppending = 8 '''' Constants for Fso text files

  Dim Act, Fso, Ts, App,Install,CName,App1

  Set Act = CreateObject("Wscript.shell")

  Set Fso = CreateObject("Scripting.FileSystemObject")

  '''' EXTRA VARIBLES FOR THE SCRIPT

  Dim Prog, UName : UName = Act.ExpandEnvironmentStrings("%UserName%")

            Prog = Act.ExpandEnvironmentStrings("%ProgramFiles%")

  Dim E_Time, EndTime, FinishTime, MyT, StartTime : StartTime = Timer : MyT = Time()

  Dim DevName,PnPName, Sp3 : Sp3 = Space(3)

  strComputer = "."

          '''' Examples For the Plug N Play ID For CD Or DVD Drive

  CheckCD = Array(_

    ("IDE\CDROMHL-DT-ST_RW/DVD_GCC-4521B_______________1.00____\5&1B4316AD&0&0.1.0"),_

    ("IDE\CDROMHL-DT-ST_CD-RW_GCE-8320B________________1.04____\5&19E23F39&0&0.0.0") )

  '''' Add the list of software to install for the first computer These | are separators

Computer1 = Array("Winamp5|msi|/Xname=Spad Xkey=XXXXX-XXXXX-XXXXX-XXXXX Xagent=1 Xlibrary=0 Xintex=1")

  '''' Add the list of software to install for the second computer

  Computer2 = Array("TweakUi|exe|/passive /qr")

''' CHECKS FOR THE CD PNP ID

Function Check_CD_App

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPEntity")

  For Each objItem in colItems

  '''' VARIBLES FOR THE LOOP

  DevName = objItem.Name

  PnPName = objItem.PNPDeviceID

  '''' CD DEVICE 1 THE ARRAY START AT ZERO EX ZERO = 1 ONE = 2 ETC

  If PnPName = CheckCD(0)Then

  '''' MAKES A NEW ARRAY FROM EXISTING ARRAY

  CName = CheckCD(0)

  CName = Replace(CName,"_______________","\")

  CName = Replace(CName,"____","\")

  CName = Split(CName,"\")

  App = Computer1(0)

  App = Split(Computer1(0) , "|")

  App1 = App(1) & " " & App(2)

    MsgBox "Confirm Match"& vbCrLf & "Software Name = " & App(0) &_

    vbCrLf & "Cd PNPID Original" & vbCrLf & CheckCD(0) &_

    vbCrLf & "Cd PNPID After Split" & vbCrLf & CName(1), 0 + 32, "Cd Confirmed"

    '''' LOOP FOR THE NEW ARRAY

    For Each StrComp1 In Computer1

    AppInstall

    Exit For

    Next

    Run_Report '''' Open The Txt File

    Exit Function

    End If

    '''' CD DEVICE 2

    If PnPName = CheckCD(1) Then

    CName = CheckCD(1)

    CName = Replace(CName,"_______________","\")

    CName = Replace(CName,"____","\")

    CName = Split(CName,"\")

    App = Computer2(1)

  App = Split(Computer2(1) , "|")

    App1 = App(1) & " " & App(2)

    MsgBox "Confirm Match"& vbCrLf & "Software Name = " & App(0) &_

    vbCrLf & "Cd PNPID Original" & vbCrLf & CheckCD(0) &_

    vbCrLf & "Cd PNPID After Split" & vbCrLf & CName(1), 0 + 32, "Cd Confirmed"

    '''' LOOP FOR THE NEW ARRAY

    For Each StrComp2 In Computer2

    AppInstall

    Exit For

    Next

    Run_Report '''' Open The Txt File

    Exit Function

    End If

  '''' IF IT THE WRONG ID

  If PnPName = IsNull("") Then 

  CName1 = CheckCD(0)

  CName1 = Replace(CName1,"_______________","\")

  CName1 = Replace(CName1,"____","\")

  CName1 = Split(CName1,"\")

  CName2 = CheckCD(1)

  CName2 = Replace(CName2,"_______________","\")

  CName2 = Replace(CName2,"____","\")

  CName2 = Split(CName2,"\")

    MsgBox "This Is Not The Correct CD Or DVD PNP ID" & vbCrLf & CName1(1) &_

    vbCrLf & CName2(1), 0 + 32,"Error Wrong CD Or DVD Drive"

    End If   

  Next

  End Function

  '''' WHERE IT NOW FINDS THE LOCATION OF THE APP

  Function AppInstall

  Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

  Set ColFiles = objWMI.ExecQuery("Select * from CIM_DataFile Where FileName = '" & App(0) & "' AND Extension = '" & App(1) & "'")

  '''' JUST MAKING A TEXT FILE OF THE SEARCH THIS COULD BE TURNED INTO THE INSTALL SECTIONS

  Set Ts = Fso.CreateTextFile("ReportFile.txt")

  Ts.WriteLine Space(3) & time() & "<----- BEGIN SEARCH ----->" & Space(3) & Date() &_

  vbCrLf & Space(3) & CName(1)

  Ts.Close

  For Each objFile in colFiles

  If ColFiles.count = 0 Then

  Set Ts = Fso.OpenTextFile("ReportFile.txt",ForAppending)

  Ts.WriteLine "Cannot Find This App" & Space(3) & App(0) & "." & App(1)

  Ts.close

  Else

  '''' Extra Varibles If Needed

  FName = Ucase(objFile.FileName)

  Kbname = Ucase(objFile.FileName & "." & objFile.Extension)

  KbPath = UCase(objFile.Drive & objFile.Path)

  TheFile = KbPath & Kbname

  If Fso.FileExists(TheFile) Then

  Set Ts = Fso.OpenTextFile("ReportFile.txt",ForAppending)

      Ts.WriteLine "Array Part 1 = " & App(0) & " <-----> Array Part 2 = " &_

      App(1) & vbCrLf & "<------------------------------>"

      Ts.WriteLine "(""Select * from CIM_DataFile Where FileName = '" & App(0) & "' AND Extension = '" & App(1) & "'"")" &_

      vbCrLf & "<------------------------------>"

      Ts.WriteLine  "<------------------------------>" & vbCrLf &_

      "Act.Run(""" & KbPath & App1 & """)" & vbCrLf & "<------------------------------>"

    FinishTime = Timer

    EndTime = Timer

    E_Time = EndTime - StartTime

    E_Time = Left(E_Time,4)

    Ts.WriteLine V & "<-------------------- TEST TIME RESULTS ------------------------->"

    Ts.WriteLine Sp3 & "The Start Time : " & MyT & V & Sp3 & "The End Time : " & Time() & V &_

    Sp3 & "Time Amount Of Time The Script Ran = " & E_Time & " Seconds" & V

      Ts.Close

    Exit For

    End If

    End If

  Next

  End function

  Check_CD_App

  Function Run_Report

  Act.Run("ReportFile.txt"),1,True

  Gsm = Act.Popup("Did You Want To Keep The Report" &_

  vbCrLf & " Yes To Keep The Report" & vbCrLf & " No To Delete The Report" &_

  vbcrlf & " If Nothing Is Seleted,In" & vbCrLf & "30 seconds It Keeps The Report" &_

  vbCrLf, 30, "Keep Or Delete", 4 + 32)

  If Gsm = Vbyes Then '''' Yes

  Exit Function

  End If

  If Gsm = Vbno Then '''' No

  Fso.DeleteFile("ReportFile.txt")

  Exit Function

  End If

  If Gsm = -1 Then '''' Time Out

  Exit Function

  End If

  End Function

The Report It Produces

Green Text Would Be It Run Command.

 

  3:16:31 PM<----- BEGIN SEARCH ----->  9/27/2005

  CDROMHL-DT-ST_RW/DVD_GCC-4521B

Array Part 1 = Winamp5 <-----> Array Part 2 = msi

<------------------------------>

("Select * from CIM_DataFile Where FileName = 'Winamp5' AND Extension = 'msi'")

<------------------------------>

<------------------------------>

Act.Run("H:\UA-WORKDIR\UA-SOFTWARE\WINAMP\WINAMP5.MSI /Xname=Spad Xkey=XXXXX-XXXXX-XXXXX-XXXXX Xagent=1 Xlibrary=0 Xintex=1")

<------------------------------>

<-------------------- TEST TIME RESULTS ------------------------->

  The Start Time : 3:16:30 PM  The End Time : 3:16:47 PM  Time Amount Of Time The Script Ran = 17.3 Seconds

Link to comment
Share on other sites

Here is a VBS script that checks for the CD PNP ID

Blue Text Array Names

1:\ It has a array for the PNP ID check 

      The Array Name : CheckCD

It has 2 ID in there one is mine and the other is some one elses.

Add yours To It.

2:\ It has 2 other arrays for app to install. I use | this to separate

Example

TweakUi|exe|/passive /qr = TweakUi.exe /passive /qr

The script then check the first array, if true it checks either of these array

  Array Name 1 : Computer1

  Array Name 2 : Computer2

3:\ It the breaks either Computer1 or Computer2 into new arrays

  Array Name : App

4:\ It then Uses the information to start a search for the app

Saves As WHAT_EVER_YOU_WANT.vbs

  Const ForReading = 1, ForWriting = 2,ForAppending = 8 '''' Constants for Fso text files

  Dim Act, Fso, Ts, App,Install,CName,App1

  Set Act = CreateObject("Wscript.shell")

  Set Fso = CreateObject("Scripting.FileSystemObject")

  '''' EXTRA VARIBLES FOR THE SCRIPT

  Dim Prog, UName : UName = Act.ExpandEnvironmentStrings("%UserName%")

            Prog = Act.ExpandEnvironmentStrings("%ProgramFiles%")

  Dim E_Time, EndTime, FinishTime, MyT, StartTime : StartTime = Timer : MyT = Time()

  Dim DevName,PnPName, Sp3 : Sp3 = Space(3)

  strComputer = "."

           '''' Examples For the Plug N Play ID For CD Or DVD Drive

  CheckCD = Array(_

    ("IDE\CDROMHL-DT-ST_RW/DVD_GCC-4521B_______________1.00____\5&1B4316AD&0&0.1.0"),_

    ("IDE\CDROMHL-DT-ST_CD-RW_GCE-8320B________________1.04____\5&19E23F39&0&0.0.0") )

   '''' Add the list of software to install for the first computer These | are separators

Computer1 = Array("Winamp5|msi|/Xname=Spad Xkey=XXXXX-XXXXX-XXXXX-XXXXX Xagent=1 Xlibrary=0 Xintex=1")

   '''' Add the list of software to install for the second computer

  Computer2 = Array("TweakUi|exe|/passive /qr")

''' CHECKS FOR THE CD PNP ID

Function Check_CD_App

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPEntity")

   For Each objItem in colItems

   '''' VARIBLES FOR THE LOOP

   DevName = objItem.Name

   PnPName = objItem.PNPDeviceID

   '''' CD DEVICE 1 THE ARRAY START AT ZERO EX ZERO = 1 ONE = 2 ETC

  If PnPName = CheckCD(0)Then

  '''' MAKES A NEW ARRAY FROM EXISTING ARRAY

   CName = CheckCD(0)

   CName = Replace(CName,"_______________","\")

   CName = Replace(CName,"____","\")

   CName = Split(CName,"\")

   App = Computer1(0)

   App = Split(Computer1(0) , "|")

   App1 = App(1) & " " & App(2)

    MsgBox "Confirm Match"& vbCrLf & "Software Name = " & App(0) &_

    vbCrLf & "Cd PNPID Original" & vbCrLf & CheckCD(0) &_

    vbCrLf & "Cd PNPID After Split" & vbCrLf & CName(1), 0 + 32, "Cd Confirmed"

    '''' LOOP FOR THE NEW ARRAY

    For Each StrComp1 In Computer1

    AppInstall

     Exit For

    Next

     Run_Report '''' Open The Txt File

     Exit Function

    End If

    '''' CD DEVICE 2

    If PnPName = CheckCD(1) Then

    CName = CheckCD(1)

    CName = Replace(CName,"_______________","\")

    CName = Replace(CName,"____","\")

    CName = Split(CName,"\")

    App = Computer2(1)

   App = Split(Computer2(1) , "|")

    App1 = App(1) & " " & App(2)

    MsgBox "Confirm Match"& vbCrLf & "Software Name = " & App(0) &_

    vbCrLf & "Cd PNPID Original" & vbCrLf & CheckCD(0) &_

    vbCrLf & "Cd PNPID After Split" & vbCrLf & CName(1), 0 + 32, "Cd Confirmed"

    '''' LOOP FOR THE NEW ARRAY

    For Each StrComp2 In Computer2

    AppInstall

     Exit For

     Next

     Run_Report '''' Open The Txt File

     Exit Function

    End If

   '''' IF IT THE WRONG ID

   If PnPName = IsNull("") Then  

   CName1 = CheckCD(0)

   CName1 = Replace(CName1,"_______________","\")

   CName1 = Replace(CName1,"____","\")

   CName1 = Split(CName1,"\")

   CName2 = CheckCD(1)

   CName2 = Replace(CName2,"_______________","\")

   CName2 = Replace(CName2,"____","\")

   CName2 = Split(CName2,"\")

    MsgBox "This Is Not The Correct CD Or DVD PNP ID" & vbCrLf & CName1(1) &_

    vbCrLf & CName2(1), 0 + 32,"Error Wrong CD Or DVD Drive"

    End If    

   Next

  End Function

  '''' WHERE IT NOW FINDS THE LOCATION OF THE APP

  Function AppInstall

  Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

  Set ColFiles = objWMI.ExecQuery("Select * from CIM_DataFile Where FileName = '" & App(0) & "' AND Extension = '" & App(1) & "'")

  '''' JUST MAKING A TEXT FILE OF THE SEARCH THIS COULD BE TURNED INTO THE INSTALL SECTIONS

  Set Ts = Fso.CreateTextFile("ReportFile.txt")

   Ts.WriteLine Space(3) & time() & "<----- BEGIN SEARCH ----->" & Space(3) & Date() &_

   vbCrLf & Space(3) & CName(1)

   Ts.Close

  For Each objFile in colFiles

  If ColFiles.count = 0 Then

  Set Ts = Fso.OpenTextFile("ReportFile.txt",ForAppending)

  Ts.WriteLine "Cannot Find This App" & Space(3) & App(0) & "." & App(1)

  Ts.close

   Else

  '''' Extra Varibles If Needed

  FName = Ucase(objFile.FileName)

  Kbname = Ucase(objFile.FileName & "." & objFile.Extension)

  KbPath = UCase(objFile.Drive & objFile.Path)

  TheFile = KbPath & Kbname

   If Fso.FileExists(TheFile) Then

   Set Ts = Fso.OpenTextFile("ReportFile.txt",ForAppending)

      Ts.WriteLine "Array Part 1 = " & App(0) & " <-----> Array Part 2 = " &_

      App(1) & vbCrLf & "<------------------------------>"

      Ts.WriteLine "(""Select * from CIM_DataFile Where FileName = '" & App(0) & "' AND Extension = '" & App(1) & "'"")" &_

      vbCrLf & "<------------------------------>"

      Ts.WriteLine  "<------------------------------>" & vbCrLf &_

      "Act.Run(""" & KbPath & App1 & """)" & vbCrLf & "<------------------------------>"

     FinishTime = Timer

     EndTime = Timer

     E_Time = EndTime - StartTime

     E_Time = Left(E_Time,4)

     Ts.WriteLine V & "<-------------------- TEST TIME RESULTS ------------------------->"

     Ts.WriteLine Sp3 & "The Start Time : " & MyT & V & Sp3 & "The End Time : " & Time() & V &_

     Sp3 & "Time Amount Of Time The Script Ran = " & E_Time & " Seconds" & V

      Ts.Close

     Exit For

    End If

    End If

   Next

  End function

  Check_CD_App

  Function Run_Report

  Act.Run("ReportFile.txt"),1,True

  Gsm = Act.Popup("Did You Want To Keep The Report" &_

  vbCrLf & " Yes To Keep The Report" & vbCrLf & " No To Delete The Report" &_

  vbcrlf & " If Nothing Is Seleted,In" & vbCrLf & "30 seconds It Keeps The Report" &_

  vbCrLf, 30, "Keep Or Delete", 4 + 32)

  If Gsm = Vbyes Then '''' Yes

   Exit Function

  End If

  If Gsm = Vbno Then '''' No

  Fso.DeleteFile("ReportFile.txt")

   Exit Function

  End If

  If Gsm = -1 Then '''' Time Out

   Exit Function

  End If

  End Function

The Report It Produces

Green Text Would Be It Run Command.

  

   3:16:31 PM<----- BEGIN SEARCH ----->   9/27/2005

   CDROMHL-DT-ST_RW/DVD_GCC-4521B

Array Part 1 = Winamp5 <-----> Array Part 2 = msi

<------------------------------>

("Select * from CIM_DataFile Where FileName = 'Winamp5' AND Extension = 'msi'")

<------------------------------>

<------------------------------>

Act.Run("H:\UA-WORKDIR\UA-SOFTWARE\WINAMP\WINAMP5.MSI /Xname=Spad Xkey=XXXXX-XXXXX-XXXXX-XXXXX Xagent=1 Xlibrary=0 Xintex=1")

<------------------------------>

<-------------------- TEST TIME RESULTS ------------------------->

   The Start Time : 3:16:30 PM   The End Time : 3:16:47 PM   Time Amount Of Time The Script Ran = 17.3 Seconds

whoa...thats quite a script there...wish i could understand it!!!

thx for posting but its not really what i had in mind, however the links that Yzöwl posted look promising...

thx both of you!

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