Welcome to WiseSoft.co.uk!
Register
About
Contact
Donate
Home
Scripts
Articles
Software
Forum
Links
Active Directory Schema Guide
Submit a Script
All Scripts
Active Directory
Computer
Database
Event Logs
Exchange/Email
File System
General
Printer
SQL Server
Account Page
Address Page
COMPlus Page
DialIn Page
Environment Page
General Page
MemberOf Page
Organization Page
Profile Page
RemoteControl Page
Sessions Page
Telephones Page
TerminalServices Page
Batch File
HTA
KiXtart
PowerShell
T-SQL
VB
VBScript
Computer Accounts
Domains, Forests & Trusts
Groups
Monitoring & Replication
Organizational Units
Schema Information
Search
Sites and Subnets
User Accounts
PowerShell
VBScript
VBScript
PowerShell
VBScript
VBScript
VBScript
VBScript
VBScript
PowerShell
VBScript
VBScript
PowerShell
VBScript
HTA
KiXtart
PowerShell
VB
VBScript
VBScript
KiXtart
PowerShell
VBScript
PowerShell
VBScript
Batch File
KiXtart
PowerShell
VBScript
HTA
VB
VBScript
HTA
KiXtart
PowerShell
VBScript
HTA
PowerShell
T-SQL
VBScript
All Articles
Active Directory
Miscellaneous
Programming
Scripting
Security
SQL Server
WiseSoft
Submit Article
All Software
TSQL DDL Code History Tool
Account Management Spreadsheet
Bulk AD Users
Password Control
Script Builder
NTFSFix
TSQL DDL Code History Tool
Bulk AD Users
Password Control
Script Builder
Account Management Spreadsheet
NTFSFix
Scripting
Guestbook
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Login
User Name:
Password:
Remember me next time
Forgot Password?
Login using OpenID:
Create free account
Exclusive access for registered users
Registered Users:
20870
Click here to find out how you can help support wisesoft.co.uk!
home
recent topics
recent posts
search
faq
AspNetForum v.5.2.7.0
WiseSoft :: Forum
:: Forum
user:
psw:
remember me
|
lost password
|
register
Home
»
Scripting
»
Loop and Check process
|
1/11/2012 6:24:25 AM
permalink
rodrigovecchi
Posts 1
Hello guys,
I need some help to improve a script I created.
I'm new in this world of scripst, and I'm doing a VBS to start a massive deploy of Office 2010.
Script show a message to user close all applications and then the script check if all applications are closed to begin the installation. While script detects process running, show a message to user close the applications.
But, in the script I check process per process, and, if a user open a process after the script had verified it, the script will proceed with the process running.
There's a way to do it better?
This is this part of the script:
'-----------------------------------------------------------------
'Verify running process
'-----------------------------------------------------------------
DIM strComputer,strProcess
strComputer = "." ' local computer
Do
' Check if winword.exe is running
strProcess = "winword.exe"
controle = "0"
if isProcessRunning(strComputer,strProcess) then
controle = "1"
else
controle = "0"
end if
result = MsgBox ("Existem aplicações abertas!" & Chr(10) &_
"Favor fecha-las antes de prosseguir!")
Loop While controle > 0
Do
' Check if excel.exe is running
strProcess = "excel.exe"
controle = "0"
if isProcessRunning(strComputer,strProcess) then
controle = "1"
else
controle = "0"
end if
result = MsgBox ("Existem aplicações abertas!" & Chr(10) &_
"Favor fecha-las antes de prosseguir!")
Loop While controle > 0
Do
' Check if outlook.exe is running
strProcess = "outlook.exe"
controle = "0"
if isProcessRunning(strComputer,strProcess) then
controle = "1"
else
controle = "0"
end if
result = MsgBox ("Existem aplicações abertas!" & Chr(10) &_
"Favor fecha-las antes de prosseguir!")
Loop While controle > 0
Do
' Check if powerpnt.exe is running
strProcess = "powerpnt.exe"
controle = "0"
if isProcessRunning(strComputer,strProcess) then
controle = "1"
else
controle = "0"
end if
result = MsgBox ("Existem aplicações abertas!" & Chr(10) &_
"Favor fecha-las antes de prosseguir!")
Loop While controle > 0
' Function to check if a process is running
function isProcessRunning(byval strComputer,byval strProcessName)
Dim objWMIService, strWMIQuery
strWMIQuery = "Select * from Win32_Process where name like '" & strProcessName & "'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
if objWMIService.ExecQuery(strWMIQuery).Count > 0 then
isProcessRunning = true
else
isProcessRunning = false
end if
end function
_____________________________________________________________________________
Regards,
pages:
1
|
Home
»
Scripting
»
Loop and Check process