VBS program for single window xplorer2

Support for xplorer² free lite version

Moderators: fgagnon, nikos, Site Mods

maoserr
New Member
Posts: 5
Joined: 2007 Mar 25, 06:13

VBS program for single window xplorer2

Post by maoserr »

If you have wscript enabled on your comp (most XP systems should), you could try the following script.

save this as checkmulti.vbs in your xplorer2 directory, and change the x2path & x2op to your setting.

Code: Select all

Option Explicit
Dim objWMIService,colProcessList,objProcess
Dim objShell,ArgNum,x2path,x2opt,Param

'Define xplorer2 path
x2path="""%Programfiles%\zabkat\xplorer2\xplorer2_UC.exe """
'Define optional flags
x2opt="/T "

'Check input arguments
ArgNum=WScript.Arguments.Count
If ArgNum=0 Then
	Param=""
Else
	Param=WScript.Arguments.Item(0)
End If

'Check process and start shell
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'xplorer2_UC.exe'")
Set objShell=CreateObject("WScript.Shell")

'Check process
If colProcessList.Count=0 Then
	'No current process, start new
	objShell.Run x2path & x2opt & """" & Param & """"
Else
	'Show current
	objShell.AppActivate("xplorer")
	'objShell.Sendkeys "^{INSERT}"
	objShell.SendKeys "{F10}{BS}{BS}" & Param & "~"
End If
And change the following registry settings:
ssave this as x2.reg and run it.

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\open_x2\command]
@="wscript \"C:\\Program Files\\zabkat\\xplorer2\\checkmulti.vbs\" \"%1\""

[HKEY_CLASSES_ROOT\Folder\shell\open_x2\command]
@="wscript \"C:\\Program Files\\zabkat\\xplorer2\\checkmulti.vbs\" \"%1\""
And this should prevent xplorer2 from opening up more than 1 window. Also if you want it to open up anything in a new tab, try uncommenting the second to last line.

I only tested this on my own computer, so I don't know if it'll work for others. Just figure other people might want to prevent multiple windows since it's annoying to me.
User avatar
nikos
Site Admin
Site Admin
Posts: 16296
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

some people have posted autohotkey macros for the same task. What you're doing could also be done with bSingleWindow registry option
maoserr
New Member
Posts: 5
Joined: 2007 Mar 25, 06:13

Post by maoserr »

nikos wrote:some people have posted autohotkey macros for the same task. What you're doing could also be done with bSingleWindow registry option
Yea I saw that, it doesn't work for me. I followed the registry instructions and changed the DWORD in the xplorer_UC directory. Maybe I'm doing something wrong, IDK, I followed the registry instructions, but it wasn't too much trouble to make this script.

If this setting's suppose to work like that, please let me know what's wrong with my computer :-/

Edit: Ok I did a little bit of testing, it appears it is working correctly if I pass a path to it. But I just had a shortcut to xplorer2 on my desktop which I click on, and that opened up new windows. This can be fixed by appending an argument to the end of the shortcut, so no biggie.

But the other problem is that xplorer2 isn't raised when I do pass a path to it, it just blinks on my taskbar. I don't suppose there's a setting for that?
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

yes, add the  /M  switch to the command line. ;)
maoserr
New Member
Posts: 5
Joined: 2007 Mar 25, 06:13

Post by maoserr »

fgagnon wrote:yes, add the  /M  switch to the command line. ;)
Ok, thanks, but I probably have this wrong again:

I have

Code: Select all

%Programfiles%\zabkat\xplorer2\xplorer2_UC.exe /M "C:"
in my target box now, but it's still just flashing it. I also changed my registry to include the switch. Still not getting a raise window when it's already open.
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

try

Code: Select all

"%Programfiles%\zabkat\xplorer2\xplorer2_UC.exe" /M C:\
or

Code: Select all

"C:\Program Files\zabkat\xplorer2\xplorer2_UC.exe" /M C:\
(the latter assuming on your machine that
%Programfiles% is synonym for C:\Program Files )
Please note the position of the quotation marks.
_________________________________________________________________
maoserr
New Member
Posts: 5
Joined: 2007 Mar 25, 06:13

Post by maoserr »

Well I already tried all possible combination of quotation marks, double quote, single quote, no quotes. I think it's reading the switch right. Maybe it just won't allow it to be in minimized mode, but it won't care if it's not in the foreground. If it makes any difference I'm also running Litestep with a lot of other customizations, but I don't think visual settings should matter that much...
User avatar
nikos
Site Admin
Site Admin
Posts: 16296
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

getting it in the foreground is the only reason you have to resort to scripts. Does yours bring it to the front?
maoserr
New Member
Posts: 5
Joined: 2007 Mar 25, 06:13

Post by maoserr »

nikos wrote:getting it in the foreground is the only reason you have to resort to scripts. Does yours bring it to the front?
Yea, but that script does some other things. So I guess the only useful thing it does is

Code: Select all

objShell.AppActivate("xplorer")
So the full code would be something like

Code: Select all

Option Explicit
Dim objShell,ArgNum,x2path,x2opt,Param

'Define xplorer2 path
x2path="""%Programfiles%\zabkat\xplorer2\xplorer2_UC.exe """
'Define optional flags
x2opt="/T "

'Check input arguments
ArgNum=WScript.Arguments.Count
If ArgNum=0 Then
	Param=""
Else
	Param=WScript.Arguments.Item(0)
End If

'Run xplorer
Set objShell=CreateObject("WScript.Shell")
objShell.Run x2path & x2opt & """" & Param & """"
'Show current
objShell.AppActivate("xplorer")
Although it's fairly simple that it might be easier to have xplorer run the one liner everytime it opens through a macro or something.[/code]