Re: Script running infinitely when calling wscript.exe from code

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"mayayana" <mayaXXyana@xxxxxxxxx> wrote in message
news:uElVOiVXKHA.4688@xxxxxxxxxxxxxxxxxxxxxxx

If Not Right(Wscript.FullName, 12) = "\WSCRIPT.EXE" Then
CreateObject("Wscript.Shell").Run "wscript.exe " &
Wscript.ScriptFullName
Wscript.Quit
End If


While we're splitting hairs...:)

I think you also need UCase there. You can
search for a file case-insensitive but string
operations are at root numeric and therefore
case-sensitive:

Dim s
s = "abcd"
If Right(s, 2) = "CD" Then
MsgBox "Match."
Else
MsgBox "No match."
End If

WScript.exe is named with all caps on my PC,
but I wouldn't want to depend on that. Microsoft
seems to be fairly willy nilly about that sort of thing.
(The other day I downloaded a VB6 service pack
full of .ocx files. The file extensions alone had at
least 3 different cap. versions: .ocx, .OCX, .Ocx )

FWIW, I checked prior to posting. Wscript.FullName always returns upper case
(on my Win98 system at least) regardless of actual host name. For my
testing, I created a copy of each host and renamed it to "Foo_Bar_Baz.exe"
and ran this.

Wscript.Echo Wscript.FullName

The full LFN was returned in all caps.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

.



Relevant Pages