Re: Do...Loop search execution problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Feb 23, 3:18 am, "ThatsIT.net.au" <me@thatsit> wrote:
<mrguerre...@xxxxxxxxx> wrote in message

news:1172165584.233458.212680@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi-
I've patched some code together for a script that will (hopefully)
delete an icon when the script detects that the cd the icon is linked
to is no longer in the drive. This is part of an HTA file I've created
for software support/installation.

Problem is that when the script loops that it doesn't actually search
again. I've tried playing with the placement of the do...loop stuff
but all I've succeeded in doing is getting the "loop without do"
error. The rest of the script works great but halfway isn't complete.
Here's the offending code...

this code needs to be in the loop, you need to reexecute the query to check
if the colFiles.Count = 0

Set colFiles = objWMIService.ExecQuery _
("Select * From CIM_DataFile Where FileName = 'autorun' " & _
"AND Extension = 'hta' AND Drive = '" & strDrive & "'")

start the loop with somthing like

dim aCount
aCount = 1

do until aCount = 0

Set colFiles = objWMIService.ExecQuery _
("Select * From CIM_DataFile Where FileName = 'autorun' " & _
"AND Extension = 'hta' AND Drive = '" & strDrive & "'")

aCount = colFiles.Count

' your code here

loop



strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_CDROMDrive")
For Each objItem in colItems
strDrive = objItem.Drive

Set colFiles = objWMIService.ExecQuery _
("Select * From CIM_DataFile Where FileName = 'autorun' " & _
"AND Extension = 'hta' AND Drive = '" & strDrive & "'")
Do
Do While colFiles.Count = 1
wScript.Sleep 10000

If colFiles.Count = 0 Then
Exit Do
End If
Loop
Loop Until colFiles.Count = 0

Set fso = CreateObject("Scripting.FileSystemObject")
ThisDrive = fso.GetDriveName(currdir)
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(strDesktop & "\cdrom.lnk")

Set objFSO = CreateObject("Scripting.FileSystemObject")
strScript = Wscript.ScriptFullName
objFSO.DeleteFile(strScript)

Next
WScript.quit

Thanks for the help in advance

Thanks. I appreciate the help. immensely

.



Relevant Pages

  • Re: Do...Loop search execution problem
    ... I've patched some code together for a script that will ... delete an icon when the script detects that the cd the icon is linked ... but all I've succeeded in doing is getting the "loop without do" ... dim aCount ...
    (microsoft.public.scripting.vbscript)
  • Do...Loop search execution problem
    ... I've patched some code together for a script that will ... delete an icon when the script detects that the cd the icon is linked ... but all I've succeeded in doing is getting the "loop without do" ... Set objFSO = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Report in FM 6 or 7
    ... achieve this report format will have to be done via scripting. ... but they will simplify the script and Sort Order. ... End Loop ... The normal 'Dancer' field is used so that if there are more than one ...
    (comp.databases.filemaker)
  • Re: recreate database script not work
    ... I got a script which is supposed to regenerate database systax. ... REM gen_dbse_9.sql ... end loop; ...
    (comp.databases.oracle.server)
  • Re: How to set up a global variable in a sub-routine?
    ... the 'global variables' are more like constants ... ... single script, I need a way to tell it only once where the file is and ... So, if you construct a loop with a loop variable, you ... >programmers avoid global variables completely. ...
    (perl.beginners)