Search

Main Menu

Login
Username:

Password:

Remember me?
Anonymous

Lost Password?

Register now!

Samurize Forums -> Closing multiple instances faster


Pages: (2) [1] 2   ( Go to first unread post ) Reply to this topicStart new topicStart Poll

> Closing multiple instances faster, using .vbs
Silvayn
Posted: Sep 30 2004, 03:23 PM
Quote Post
Shadow
*



Group: Member
Joined: Jul 21 2004
Posts: 24
Offline



I have a button on my config which closes all samurize instances that I use. I naturally tried using client.exe's close parameter to this, but found out that it's slower than a .vbs solution. Also, in case it's trying to close a non-running config, it will open it first and then close.

The following .vbs code isn't my doing, I just edited a bit to make closing multiple instances easy. I unfortunatelly don't remember who the original author is.

Here goes...

CODE
iOther = "Default|WEATHER|Additional|NEWS"

'No editing below this point required
'------------------------------------
dim WshShell, Instances, Path, ItoCLOSE

set WshShell = CreateObject("WScript.Shell")
set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

If (Len(iOther) > 0) then
If Not InStr(iOther,"|") then iOther = iOther & "|"
Instances = Split(iOther,"|")
If (UBound(Instances)>0) then
 For each Instance in Instances
  If (Len(Instance) > 0) then
   ItoCLOSE=Instance
   Close
  End If
 Next
End If
End If

Function Close()
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process where CommandLine LIKE  '%Client.exe% i=" & ItoCLOSE & "%' ",,48)
For Each objItem in colItems  
 PID = objItem.ProcessID  
Next
Test = WshShell.AppActivate(PID)
If test = True then WshShell.SendKeys "%{F4}"
end Function


Just edit the "iOther" constant in the beginning to fit your needs (names). Use | to separate.

Hope you'll find it useful. smiles-2thumbsup.gif
PMEmail PosterICQ
Top
KMDonlon
  Posted: Sep 30 2004, 08:31 PM
Quote Post
The Weather Freak
*****



Group: Member
Joined: Feb 19 2004
Posts: 3,535
Offline



How do you mean this is faster than using the command line option. I would think any use of a .vbs with a refresh rate low enough to make the button work quick enough would use mega CPU cycles, dunno but hope you can explain further. smil3dbd4d6422f04.gif


--------------------
PMEmail PosterICQAOLYahooMSN
Top
NeM
Posted: Sep 30 2004, 09:01 PM
Quote Post
Ex-Dev
****



Group: Admin
Joined: Sep 25 2003
Posts: 832
Offline



The close shouldn't be slow? It's pretty snappy here.

Though the close thing when the client is not running can be fixed.
PMEmail PosterICQMSN
Top
KMDonlon
  Posted: Sep 30 2004, 09:08 PM
Quote Post
The Weather Freak
*****



Group: Member
Joined: Feb 19 2004
Posts: 3,535
Offline



Same here, I have a close button on a couple of my configs I don't use very much and it closes really quick even with a config refresh rate of 1500ms...


--------------------
PMEmail PosterICQAOLYahooMSN
Top
Silvayn
Posted: Oct 1 2004, 09:51 AM
Quote Post
Shadow
*



Group: Member
Joined: Jul 21 2004
Posts: 24
Offline



No idea why it's faster for me. Maybe because norton av running in the background is slowing things down? Oh well, ignore it then smil3dbd4d6422f04.gif
PMEmail PosterICQ
Top
XoD
Posted: Oct 1 2004, 04:26 PM
Quote Post
Shadow
*



Group: Member
Joined: Sep 10 2004
Posts: 2
Offline



Starting my 7 Instances just takes 2 secs and closing all per commandline a bit over 1 sec.
PM
Top
KMDonlon
  Posted: Oct 1 2004, 04:30 PM
Quote Post
The Weather Freak
*****



Group: Member
Joined: Feb 19 2004
Posts: 3,535
Offline



I run AV in the background too, so not sure...


--------------------
PMEmail PosterICQAOLYahooMSN
Top
Silvayn
Posted: Oct 2 2004, 06:23 PM
Quote Post
Shadow
*



Group: Member
Joined: Jul 21 2004
Posts: 24
Offline



Ok, I figured out why it was slow for me when I tried it. It was because the first instance that I was trying to close wasn't always running. Thus loading it first and then closing (it's a net-info fetching instance) slowed closing of others.
PMEmail PosterICQ
Top
cyberbeer
Posted: Oct 24 2004, 06:29 AM
Quote Post
Shadow
*



Group: Member
Joined: Aug 22 2004
Posts: 2
Offline



How do you close multiple instances with the commandline for client? im running 2 instances named tvprogram and channel and want by one click to close them both! Cant seem to find it anywhere!
CyberBeer
PM
Top
AdamC
Posted: Oct 24 2004, 06:46 AM
Quote Post
The Programming Frog
*****



Group: Admin
Joined: Sep 26 2003
Posts: 2,496
Offline



You use:

c:\program files\samurize\client i=tvprogram Close
c:\program files\samurize\client i=channel Close
PMICQAOLYahooMSN
Top
cyberbeer
Posted: Oct 24 2004, 07:02 AM
Quote Post
Shadow
*



Group: Member
Joined: Aug 22 2004
Posts: 2
Offline



Not quit the reply i needed! I need to know how to close 2 instances by only one click! I was thinking of something like this Client.exe i=tvprogram i=channel close! I know the commands for the close option. But how to close multiple instances is what im looking for! The one thing u wrote doesn't work! It works if i have 2 buttons but not one!
PM
Top
Nappi
Posted: Oct 24 2004, 07:52 AM
Quote Post
Ronin
****



Group: Moderating Crew
Joined: Sep 26 2003
Posts: 748
Offline



Just make two separate meters with the links AdamC gave and place them on top of each other... smil3dbd4d6422f04.gif


--------------------
PMEmail PosterMSN
Top
jon.derby
Posted: Oct 24 2004, 10:40 AM
Quote Post
Ninja
**



Group: Samurize VIP
Joined: Mar 20 2004
Posts: 77
Offline



cyberbeer, have a look at my post in Expanding and Collapsing, Expanding&Collapsing two at a time! and just change
CODE
Dim Instances(1)
Instances(0) = "i=Weather c=WeatherBig reload"
Instances(1) = "i=UKTV    c=UKTVBig    reload"

to (but with your instance names)
CODE
Dim Instances(1)
Instances(0) = "i=Weather close"
Instances(1) = "i=UKTV    close"
PM
Top
LimDul
Posted: Oct 24 2004, 12:39 PM
Quote Post
The Lazy Admin
***



Group: Admin
Joined: Sep 30 2003
Posts: 149
Offline



QUOTE (cyberbeer @ Oct 24 2004, 02:02 PM)
Not quit the reply i needed! I need to know how to close 2 instances by only one click! I was thinking of something like this Client.exe i=tvprogram i=channel close! I know the commands for the close option. But how to close multiple instances is what im looking for! The one thing u wrote doesn't work! It works if i have 2 buttons but not one!

please try using less ! and more . in your posts
PMEmail PosterICQMSN
Top
VAN
Posted: Nov 8 2004, 12:01 AM
Quote Post
Shadow
*



Group: Member
Joined: Nov 5 2004
Posts: 4
Offline



this looks confusing. i'll just create a bat file instead.
PM
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages: (2) [1] 2  Reply to this topicStart new topicStart Poll

 

Come On, Get Samurized!