Windows Vista Forums

Run Exe From a CD with wildcard
  1. #1


    Oli M Guest

    Run Exe From a CD with wildcard

    Ive created a script that downloads internet updates (exe files) and then
    burns then to a cd.

    What i Want to do is also burn an autorun that runs a script from the cd
    when the cd is inserted and then runs the exe files from the cd.
    The problem is the files change name everyday
    For example one day it will be sdat5555.exe and then the next sdat5556.exe



    Is there any way i can put a wildcard into my script that will search the cd
    for any files names starting with sdat and ending in .exe and then install
    them?

      My System SpecsSystem Spec

  2. #2


    Pegasus [MVP] Guest

    Re: Run Exe From a CD with wildcard


    "Oli M" <OliM@xxxxxx> wrote in message
    news:53C7C7AE-346D-4FAA-B82E-917526BA14BD@xxxxxx

    > Ive created a script that downloads internet updates (exe files) and then
    > burns then to a cd.
    >
    > What i Want to do is also burn an autorun that runs a script from the cd
    > when the cd is inserted and then runs the exe files from the cd.
    > The problem is the files change name everyday
    > For example one day it will be sdat5555.exe and then the next sdat5556.exe
    >
    > Is there any way i can put a wildcard into my script that will search the
    > cd
    > for any files names starting with sdat and ending in .exe and then install
    > them?
    In your last paragraph you write "install them". Presumably you mean "run
    them" or "execute them". If so then you could get autorun to invoke the
    following batch file:

    @echo off
    for /F "delims=" %%a in ('dir /b /s \sdat*.exe') do "%%a"

    Do not retype this batch file - use copy & paste instead!



      My System SpecsSystem Spec

  3. #3


    Oli M Guest

    Re: Run Exe From a CD with wildcard

    Thanks very much.

    I don't want to do it in a batch file though, as the vbs script I have does
    other things as well and I want it all in one script.

    Is there anyway of doing that in a vbs script?

    "Pegasus [MVP]" wrote:

    >
    > "Oli M" <OliM@xxxxxx> wrote in message
    > news:53C7C7AE-346D-4FAA-B82E-917526BA14BD@xxxxxx

    > > Ive created a script that downloads internet updates (exe files) and then
    > > burns then to a cd.
    > >
    > > What i Want to do is also burn an autorun that runs a script from the cd
    > > when the cd is inserted and then runs the exe files from the cd.
    > > The problem is the files change name everyday
    > > For example one day it will be sdat5555.exe and then the next sdat5556.exe
    > >
    > > Is there any way i can put a wildcard into my script that will search the
    > > cd
    > > for any files names starting with sdat and ending in .exe and then install
    > > them?
    >
    > In your last paragraph you write "install them". Presumably you mean "run
    > them" or "execute them". If so then you could get autorun to invoke the
    > following batch file:
    >
    > @echo off
    > for /F "delims=" %%a in ('dir /b /s \sdat*.exe') do "%%a"
    >
    > Do not retype this batch file - use copy & paste instead!
    >
    >
    >

      My System SpecsSystem Spec

  4. #4


    Pegasus [MVP] Guest

    Re: Run Exe From a CD with wildcard


    "Oli M" <OliM@xxxxxx> wrote in message
    news:6F3A461D-7D12-45F1-9165-21C0C9307D93@xxxxxx

    > Thanks very much.
    >
    > I don't want to do it in a batch file though, as the vbs script I have
    > does
    > other things as well and I want it all in one script.
    >
    > Is there anyway of doing that in a vbs script?
    >
    Sure - use the File System Object to search all CD folders recursively for
    sdat*.exe, then use the Run method to execute the file you find. It's the
    same idea but it probably takes ten lines of code instead of one.



      My System SpecsSystem Spec

  5. #5


    Oli M Guest

    Re: Run Exe From a CD with wildcard

    Ah ok. One small thing.
    I would I got about doing that

    What would the ten lines of code be.

    Im still a newbie at this

    "Pegasus [MVP]" wrote:

    >
    > "Oli M" <OliM@xxxxxx> wrote in message
    > news:6F3A461D-7D12-45F1-9165-21C0C9307D93@xxxxxx

    > > Thanks very much.
    > >
    > > I don't want to do it in a batch file though, as the vbs script I have
    > > does
    > > other things as well and I want it all in one script.
    > >
    > > Is there anyway of doing that in a vbs script?
    > >
    >
    > Sure - use the File System Object to search all CD folders recursively for
    > sdat*.exe, then use the Run method to execute the file you find. It's the
    > same idea but it probably takes ten lines of code instead of one.
    >
    >
    >

      My System SpecsSystem Spec

  6. #6


    Pegasus [MVP] Guest

    Re: Run Exe From a CD with wildcard


    "Oli M" <OliM@xxxxxx> wrote in message
    news:1ABFE01F-C72A-4B5B-9876-D9A801A7AEA1@xxxxxx

    > Ah ok. One small thing.
    > I would I got about doing that
    >
    > What would the ten lines of code be.
    >
    > Im still a newbie at this
    I'm intrigued. First you reject a single-line batch file solution (whose
    operation is fairly easy to understand), then you request a full VB Script
    solution because you do not yet have the experience to write the code in
    this language of your choice. This wouldn't be a study course assignment,
    would it?

    Here is the recursive part of the solution. You must invoke it with
    cscript.exe.

    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.GetFolder("F:\")
    GetFiles(oFolder)

    Sub GetFiles(oFldr)
    For Each oFile In oFldr.Files
    WScript.Echo oFile.path
    Next
    For Each oSubFolder In oFldr.Subfolders
    GetFiles(oSubFolder)
    Next
    End Sub

    You can use it as the basis for the remaining tasks, i.e.
    - Pick the files that match your wildcard spec;
    - Use the Run method to invoke the executable you found.

    You will find everything you need in the downloadable help file
    script56.chm. Look for the "left" and "right" functions and for the "run" or
    "exec" methods.



      My System SpecsSystem Spec

  7. #7


    ekkehard.horner Guest

    Re: Run Exe From a CD with wildcard

    Pegasus [MVP] schrieb:

    > "Oli M" <OliM@xxxxxx> wrote in message
    > news:1ABFE01F-C72A-4B5B-9876-D9A801A7AEA1@xxxxxx
    [...]

    > Here is the recursive part of the solution. You must invoke it with
    > cscript.exe.
    >
    > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > Set oFolder = oFSO.GetFolder("F:\")
    > GetFiles(oFolder)
    >
    > Sub GetFiles(oFldr)
    > For Each oFile In oFldr.Files
    > WScript.Echo oFile.path
    > Next
    > For Each oSubFolder In oFldr.Subfolders
    > GetFiles(oSubFolder)
    > Next
    > End Sub
    >
    > You can use it as the basis for the remaining tasks, i.e.
    > - Pick the files that match your wildcard spec;
    > - Use the Run method to invoke the executable you found.
    >
    > You will find everything you need in the downloadable help file
    > script56.chm. Look for the "left" and "right" functions and for the "run" or
    > "exec" methods.
    Ok, I'll add the the 'find the .exe' sub part of the problem:

    Const csCDRoot = "<YourCDRoot>"

    Dim oFSO : Set oFSO = CreateObject( "Scripting.FileSystemObject" )
    Dim oWSH : Set oWSH = CreateObject( "WScript.Shell" )
    Dim oRE : Set oRE = New RegExp
    oRE.IgnoreCase = True
    oRE.Pattern = "^sdat\d+\.exe$" ' <== sdat5555.exe and then the next sdat5556.exe
    ExecCDFiles oFSO.GetFolder( csCDRoot ), oFSO, oRE, oWSH

    Sub ExecCDFiles( oFldr, oFSO, oRE, oWSH )
    Dim oItem
    For Each oItem In oFldr.Files
    WScript.Echo "seen ", oItem.Path
    If oRE.Test( oItem.Name ) Then
    WScript.Echo "match", oItem.Path
    End If
    Next
    For Each oItem In oFldr.Subfolders
    ExecCDFiles oItem, oFSO, oRE, oWSH
    Next
    End Sub

    [I admit that I did it mainly to remove those nasty () from Pegasus' code]

      My System SpecsSystem Spec

  8. #8


    ekkehard.horner Guest

    Re: Run Exe From a CD with wildcard

    Pegasus [MVP] schrieb:

    > "Oli M" <OliM@xxxxxx> wrote in message
    > news:1ABFE01F-C72A-4B5B-9876-D9A801A7AEA1@xxxxxx
    [...]

    > Here is the recursive part of the solution. You must invoke it with
    > cscript.exe.
    >
    > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > Set oFolder = oFSO.GetFolder("F:\")
    > GetFiles(oFolder)
    >
    > Sub GetFiles(oFldr)
    > For Each oFile In oFldr.Files
    > WScript.Echo oFile.path
    > Next
    > For Each oSubFolder In oFldr.Subfolders
    > GetFiles(oSubFolder)
    > Next
    > End Sub
    >
    > You can use it as the basis for the remaining tasks, i.e.
    > - Pick the files that match your wildcard spec;
    > - Use the Run method to invoke the executable you found.
    >
    > You will find everything you need in the downloadable help file
    > script56.chm. Look for the "left" and "right" functions and for the "run" or
    > "exec" methods.
    Ok, I'll add the the 'find the .exe' sub part of the problem:

    Const csCDRoot = "<YourCDRoot>"

    Dim oFSO : Set oFSO = CreateObject( "Scripting.FileSystemObject" )
    Dim oWSH : Set oWSH = CreateObject( "WScript.Shell" )
    Dim oRE : Set oRE = New RegExp
    oRE.IgnoreCase = True
    oRE.Pattern = "^sdat\d+\.exe$" ' <== sdat5555.exe and then the next sdat5556.exe
    ExecCDFiles oFSO.GetFolder( csCDRoot ), oFSO, oRE, oWSH

    Sub ExecCDFiles( oFldr, oFSO, oRE, oWSH )
    Dim oItem
    For Each oItem In oFldr.Files
    WScript.Echo "seen ", oItem.Path
    If oRE.Test( oItem.Name ) Then
    WScript.Echo "match", oItem.Path
    End If
    Next
    For Each oItem In oFldr.Subfolders
    ExecCDFiles oItem, oFSO, oRE, oWSH
    Next
    End Sub

    [I admit that I did it mainly to remove those nasty () from Pegasus' code]

      My System SpecsSystem Spec

  9. #9


    Pegasus [MVP] Guest

    Re: Run Exe From a CD with wildcard


    "ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message
    news:49E4BEC9.80808@xxxxxx

    > Pegasus [MVP] schrieb:

    >> "Oli M" <OliM@xxxxxx> wrote in message
    >> news:1ABFE01F-C72A-4B5B-9876-D9A801A7AEA1@xxxxxx
    > [...]

    >> Here is the recursive part of the solution. You must invoke it with
    >> cscript.exe.
    >>
    >> Set oFSO = CreateObject("Scripting.FileSystemObject")
    >> Set oFolder = oFSO.GetFolder("F:\")
    >> GetFiles(oFolder)
    >>
    >> Sub GetFiles(oFldr)
    >> For Each oFile In oFldr.Files
    >> WScript.Echo oFile.path
    >> Next
    >> For Each oSubFolder In oFldr.Subfolders
    >> GetFiles(oSubFolder)
    >> Next
    >> End Sub
    >>
    >> You can use it as the basis for the remaining tasks, i.e.
    >> - Pick the files that match your wildcard spec;
    >> - Use the Run method to invoke the executable you found.
    >>
    >> You will find everything you need in the downloadable help file
    >> script56.chm. Look for the "left" and "right" functions and for the "run"
    >> or "exec" methods.
    >
    > Ok, I'll add the the 'find the .exe' sub part of the problem:
    >
    > Const csCDRoot = "<YourCDRoot>"
    >
    > Dim oFSO : Set oFSO = CreateObject( "Scripting.FileSystemObject" )
    > Dim oWSH : Set oWSH = CreateObject( "WScript.Shell" )
    > Dim oRE : Set oRE = New RegExp
    > oRE.IgnoreCase = True
    > oRE.Pattern = "^sdat\d+\.exe$" ' <== sdat5555.exe and then the next
    > sdat5556.exe
    > ExecCDFiles oFSO.GetFolder( csCDRoot ), oFSO, oRE, oWSH
    >
    > Sub ExecCDFiles( oFldr, oFSO, oRE, oWSH )
    > Dim oItem
    > For Each oItem In oFldr.Files
    > WScript.Echo "seen ", oItem.Path
    > If oRE.Test( oItem.Name ) Then
    > WScript.Echo "match", oItem.Path
    > End If
    > Next
    > For Each oItem In oFldr.Subfolders
    > ExecCDFiles oItem, oFSO, oRE, oWSH
    > Next
    > End Sub
    >
    > [I admit that I did it mainly to remove those nasty () from Pegasus' code]
    Did you notice that the OP did not contribute a single line of code of his
    own? He prefers to get the lot delivered on a platter, free of charge, with
    no effort by himself other than holding out his hollow hand.



      My System SpecsSystem Spec

  10. #10


    ekkehard.horner Guest

    Re: Run Exe From a CD with wildcard

    Pegasus [MVP] schrieb:
    [...]

    > Did you notice that the OP did not contribute a single line of code of his
    > own? He prefers to get the lot delivered on a platter, free of charge, with
    > no effort by himself other than holding out his hollow hand.
    Yes, I agree with you; Oli M should be ashamed. But I felt that you had
    put some effort/work into the problem that could well be the base for
    a complete solution. At least, one can hope that Oli M will add the
    'execute' part of the task. If not, perhaps some other person will
    chip in some lines of code (just for fun or out of generosity). Then
    this topic will end well, even though it started badly.

      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
Run Exe From a CD with wildcard problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change filename using a wildcard touch0ph VB Script 4 20 Apr 2009
Blocking a domain using wildcard xtrailer Vista mail 1 14 Jul 2008
how to get the file name from using a wildcard Daz VB Script 8 02 Jun 2008
WildCard SSL Certificates Jeff Parrish Vista mail 0 14 Sep 2006
Wildcard searches =?Utf-8?B?ZnJhY3RhbHN1YXI=?= Vista file management 5 23 Aug 2006