Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 15th, 2008, 06:24 PM
Hangman Hangman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 29 Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 h 56 m 6 sec
Reputation Power: 0
VBScript - Verify a running program

Hey, I have a question about a subject I haven't come across yet in my book.
How do you find a particular program that is running, and tell your script to make it the active screen and close it when the script is done doing some ... clerical stuff ??
For example, you have a script that is copying files to a directory on the server (or on your personal PC). You had windows explorer running in the background from some earlier something you were doing before starting the script.
you want your script to grab the current windows explorer (which is running in the background with three other programs) and make it active, switch to the folder you are copying files to (for entertainment purposes, you want to watch the files magically appear ), and when the copying is done, close the windows explorer.
Hope that made sense. If not, I'll try again.
Thanks in advance.

Reply With Quote
  #2  
Old August 16th, 2008, 12:09 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,253 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 3 m 7 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Since Windows Explorer runs in a window you can use the WshShell object's AppActivate method. The problem is that you'll need to know what folder Explorer is open to because you'll need the exact title string. For example, on this machine, if Explorer is open to the C: drive, it looks like this:
vb Code:
Original - vb Code
  1. Set WshShell = CreateObject("WScript.Shell")
  2. result = WshShell.AppActivate("HP_PAVILION (C:)")
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
  #3  
Old September 10th, 2008, 01:52 PM
Isamu Isamu is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 1 Isamu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m
Reputation Power: 0
Verify and start and .EXE if not running

the problem I have is I have 2 .EXE that I need to verify their running state. If they are not running I need the script to throw an error code. How would I go about doing this? The 2 .EXE’s are SQLSQM.EXE, Fabric.exe

Thanks

Reply With Quote
  #4  
Old September 10th, 2008, 05:12 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,253 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 3 m 7 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
In WMI, processes are typically named by their executable. You can query the Win32_Process class for all running processes and then check an executable name against the Caption property.
vb Code:
Original - vb Code
  1. If IsRunning("SQLSQM.EXE") Then
  2.     WScript.Echo "SQLSQM.EXE is running."
  3. End If
  4.  
  5. If IsRunning("Fabric.exe") Then
  6.     WScript.Echo "Fabric.exe is running."
  7. End If
  8.  
  9. Function IsRunning(strName)
  10.     Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
  11.     Set colProcesses = objWMI.ExecQuery("Select * From Win32_Process " & _
  12.         "Where Caption = '" & strName & "'")
  13.  
  14.     If colProcesses.Count > 0 Then
  15.         IsRunning = True
  16.     Else
  17.         IsRunning = False
  18.     End If
  19. End Function
In instances where the Caption name could be different, you can check the actual executable name that was used to launch the process by checking the ExecutablePath property instead.
vb Code:
Original - vb Code
  1. Function IsRunning(strName)
  2.     IsRunning = False
  3.     Set objWMI = GetObject("winmgmts:\\.root\cimv2")
  4.     Set colProcesses = objWMI.ExecuteQuery("Select * From Win32_Processes")
  5.  
  6.     For Each objProcess In colProcesses
  7.         strPath = objProcess.ExecutablePath
  8.         If InStr(0, strPath, strName) > 0 Then IsRunning = True
  9.     Next
  10. End Function
Comments on this post
keep_it_simple agrees!

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > VBScript - Verify a running program


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT