?
Solved

What is wrong in this script?

Posted on 2011-03-21
11
Medium Priority
?
426 Views
Last Modified: 2012-05-11
What is wrong in this script?

 set s=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='iexplore.exe'"
set q=s.execquery(sQuery)
 
msgbox "Maintenance: Close Internet Explorer bla bla bla."
 
Do until q.count=0
    wscript.sleep 5000
    set q=s.execquery(sQuery)
    msgbox "still open please close..."
Loop
msgbox "Internet Explorer closed, thanks. Starting to update, have a nice day!"

Set WshShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
end if

Open in new window


Thanks a lot
hopeleonie  error
0
Comment
Question by:*** Hopeleonie ***
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +2
11 Comments
 
LVL 2

Assisted Solution

by:michael_madsen
michael_madsen earned 100 total points
ID: 35180244
You don't need "end if" in line 17 since you don't have any if statement
0
 
LVL 10

Assisted Solution

by:gavsmith
gavsmith earned 100 total points
ID: 35180256
Is that the whole script? if so line '17: end if ' shouldn't be there, as there isn't any starting 'IF' statement.

Regards
Gav
0
 
LVL 2

Assisted Solution

by:ghemstrom
ghemstrom earned 300 total points
ID: 35180277
the line 17 includes two statements: end, that ends the script, and if, that assumes that you have a condition and at least one statement.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
Angelgeo earned 1500 total points
ID: 35180351

set s=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='iexplore.exe'"
set q=s.execquery(sQuery)

If q.Count > 0 Then 
msgbox "Maintenance: Close Internet Explorer bla bla bla."
 
Do until q.count=0
    wscript.sleep 5000
    set q=s.execquery(sQuery)
    msgbox "still open please close..."
Loop
msgbox "Internet Explorer closed, thanks. Starting to update, have a nice day!"

Set WshShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
end if

Open in new window

0
 
LVL 19

Author Comment

by:*** Hopeleonie ***
ID: 35183827
@michael_madsen, gavsmith and ghemstrom
yes this is the whole script. why does angelgeo's code working "with end if" ?

@Angelgeo
your solution worked
0
 
LVL 2

Assisted Solution

by:ghemstrom
ghemstrom earned 300 total points
ID: 35184363
Because he added the condition that q had to be greater than 0, which is really unnecessary becaus the do until takes care of that - just take away the concluding if and the script will work, won´t it?
0
 
LVL 19

Author Comment

by:*** Hopeleonie ***
ID: 35184384
Hi ghemstrom

How would the code looks then?
0
 
LVL 2

Assisted Solution

by:ghemstrom
ghemstrom earned 300 total points
ID: 35184433
You just drop the last if from your code
0
 
LVL 5

Expert Comment

by:Angelgeo
ID: 35186847
Hi hopeleonie

I Add "If q.Count > 0 Then " on Line 8
for check for check is running "Internet Explorer" or no.
befor say "Close Internet Explorer bla bla"

this script is more correct


set s=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='iexplore.exe'"
set q=s.execquery(sQuery)

If q.Count > 0 Then 
msgbox "Maintenance: Close Internet Explorer bla bla bla."
end if
 
Do until q.count=0
    wscript.sleep 5000
    set q=s.execquery(sQuery)
    msgbox "still open please close..."
Loop
msgbox "Internet Explorer closed, thanks. Starting to update, have a nice day!"

Set WshShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Open in new window

0
 
LVL 5

Assisted Solution

by:Angelgeo
Angelgeo earned 1500 total points
ID: 35186877
or you can delete the last line, as said : michael_madsen, hopeleonie

and change msgbox

set s=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='iexplore.exe'"
set q=s.execquery(sQuery)

Do until q.count=0
    wscript.sleep 5000
    set q=s.execquery(sQuery)
    msgbox "Internet Explorer is open please close..."
Loop
msgbox "Internet Explorer closed, thanks. Starting to update, have a nice day!"

Set WshShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Open in new window

0
 
LVL 19

Author Closing Comment

by:*** Hopeleonie ***
ID: 35187563
Thank you to all!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question