Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Run Exe From a CD with wildcard

Reply
 
Old 04-14-2009   #1 (permalink)
Oli M


 
 

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
Old 04-14-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: Run Exe From a CD with wildcard


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

> 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
Old 04-14-2009   #3 (permalink)
Oli M


 
 

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:
Quote:

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

> > 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
Old 04-14-2009   #4 (permalink)
Pegasus [MVP]


 
 

Re: Run Exe From a CD with wildcard


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

> 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
Old 04-14-2009   #5 (permalink)
Oli M


 
 

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:
Quote:

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

> > 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
Old 04-14-2009   #6 (permalink)
Pegasus [MVP]


 
 

Re: Run Exe From a CD with wildcard


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

> 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
Old 04-14-2009   #7 (permalink)
ekkehard.horner


 
 

Re: Run Exe From a CD with wildcard

Pegasus [MVP] schrieb:
Quote:

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

> 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
Old 04-14-2009   #8 (permalink)
ekkehard.horner


 
 

Re: Run Exe From a CD with wildcard

Pegasus [MVP] schrieb:
Quote:

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

> 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
Old 04-14-2009   #9 (permalink)
Pegasus [MVP]


 
 

Re: Run Exe From a CD with wildcard


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

> Pegasus [MVP] schrieb:
Quote:

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

>> 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
Old 04-14-2009   #10 (permalink)
ekkehard.horner


 
 

Re: Run Exe From a CD with wildcard

Pegasus [MVP] schrieb:
[...]
Quote:

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

Thread Tools


Similar Threads
Thread Forum
Change filename using a wildcard VB Script
The specified wildcard pattern is not valid: [ PowerShell
how to get the file name from using a wildcard VB Script
WildCard SSL Certificates Vista mail
Wildcard searches Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46