paul01
asked on
Wscript.CreateObject
Hi
Can you help with this code, why am I getting error messages.
it high lights "Wscript" from Wscript.CreateObject as a variable, but it is not a variable.
Dim WshShell as Object
Set WshShell = Wscript.CreateObject("Wscr ipt.shell" ): Compile error, variable not defined
wshom.ocx is installed and registered on my machine and I have tried
Wscript.CreateObject("Wscr ipt.shell" )
WScript.CreateObject("WScr ipt.shell" )
WSCRIPT.CreateObject("WSCR IPT.SHELL" )
With no luck
Can you help with this code, why am I getting error messages.
it high lights "Wscript" from Wscript.CreateObject as a variable, but it is not a variable.
Dim WshShell as Object
Set WshShell = Wscript.CreateObject("Wscr
wshom.ocx is installed and registered on my machine and I have tried
Wscript.CreateObject("Wscr
WScript.CreateObject("WScr
WSCRIPT.CreateObject("WSCR
With no luck
ASKER
Thanks Wippie but already tried that one with luck
Paul,
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
Is correct - at the top of your program do you have:
Option Explicit
if so you will have to:
Dim WshShell
Hope this helps,
Bart
Set WshShell = WScript.CreateObject("WScr
Is correct - at the top of your program do you have:
Option Explicit
if so you will have to:
Dim WshShell
Hope this helps,
Bart
Hi
Set WshShell = Wscript.CreateObject("Wscr ipt.shell" ): Compile error, variable not deined
This is vbs script, not VB syntax
Set WshShell = CreateObject("Wscript.shel l"): Run time error, Activex component cant create object
1.Object types are often case sencitive, so try "WScript.Shell"
2. Check if wshom.ocx is installed and registered on your machine.
Cheers
Set WshShell = Wscript.CreateObject("Wscr
This is vbs script, not VB syntax
Set WshShell = CreateObject("Wscript.shel
1.Object types are often case sencitive, so try "WScript.Shell"
2. Check if wshom.ocx is installed and registered on your machine.
Cheers
Hi paul01,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
DELETE this question.
*** I personally had a similar needs and could never instantiate a WScript object. Has anyone tried any of these solutions?
paul01, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
DELETE this question.
*** I personally had a similar needs and could never instantiate a WScript object. Has anyone tried any of these solutions?
paul01, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
Hi
Just a comment:
>>*** I personally had a similar needs and could never instantiate a WScript object. Has anyone tried any of these solutions?<<
It's strange...
*** I personally had a similar needs and could never instantiate a WScript object. Has anyone tried any of these solutions?
Private Sub Command1_Click()
Dim WshShell As Object
Set WshShell = CreateObject("Wscript.Shel l")
WshShell.Popup "See, I'm working!!!" & vbCrLf & "I'll disapear after 3 sec.", 3, "WScript Demo", vbOKCancel
Set WshShell = Nothing
End Sub
Works fine
Cheers
Just a comment:
>>*** I personally had a similar needs and could never instantiate a WScript object. Has anyone tried any of these solutions?<<
It's strange...
*** I personally had a similar needs and could never instantiate a WScript object. Has anyone tried any of these solutions?
Private Sub Command1_Click()
Dim WshShell As Object
Set WshShell = CreateObject("Wscript.Shel
WshShell.Popup "See, I'm working!!!" & vbCrLf & "I'll disapear after 3 sec.", 3, "WScript Demo", vbOKCancel
Set WshShell = Nothing
End Sub
Works fine
Cheers
I've had no problems creating a WShell object, it's the WScript object itself... In an HTA, it provides such useful objects as the StdIn object and methods such as Sleep() that I've needed to use.
Since your code works, then it certainly appears that you have provided a PAQable answer. Lets give paul01 a few days to respond.
-- Dan
Since your code works, then it certainly appears that you have provided a PAQable answer. Lets give paul01 a few days to respond.
-- Dan
Hello Dan
If you so need these object, just use:
Dim sVBSFile As String
Private Sub Command1_Click()
Dim nFile As Integer
sVBSFile = App.Path & "\test.vbs"
nFile = FreeFile
Open sVBSFile For Output As #nFile
Print #nFile, "Set WshNetwork = WScript.CreateObject(" & Chr(34) & "WScript.Network" & Chr(34) & ")"
Print #nFile, "WScript.Echo " & Chr(34) & "Domain = " & Chr(34) & " & WshNetwork.UserDomain"
Print #nFile, "WScript.Echo " & Chr(34) & "Computer Name = " & Chr(34) & " & WshNetwork.ComputerName"
Print #nFile, "WScript.Sleep 200"
Close #nFile
Shell "wscript " & sVBSFile, vbNormalFocus
End Sub
Private Sub Form_Unload(Cancel As Integer)
Kill sVBSFile
End Sub
Cheers
If you so need these object, just use:
Dim sVBSFile As String
Private Sub Command1_Click()
Dim nFile As Integer
sVBSFile = App.Path & "\test.vbs"
nFile = FreeFile
Open sVBSFile For Output As #nFile
Print #nFile, "Set WshNetwork = WScript.CreateObject(" & Chr(34) & "WScript.Network" & Chr(34) & ")"
Print #nFile, "WScript.Echo " & Chr(34) & "Domain = " & Chr(34) & " & WshNetwork.UserDomain"
Print #nFile, "WScript.Echo " & Chr(34) & "Computer Name = " & Chr(34) & " & WshNetwork.ComputerName"
Print #nFile, "WScript.Sleep 200"
Close #nFile
Shell "wscript " & sVBSFile, vbNormalFocus
End Sub
Private Sub Form_Unload(Cancel As Integer)
Kill sVBSFile
End Sub
Cheers
Thanks Ark. Executing an external script is certainly one technique. It seems a long way to go to execute Sleep(0) in order to give up a timeslice -- and anyway, I think that that program would run concurrently with the calling program. However, it does provide a way to access some of the other services provided by the WScript object. Thanks.
-- Dan
-- Dan
Hi Dan
It was just a joke :)
Cheers
It was just a joke :)
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There's no object in vb called Wscript...so variable really isn't defined...
2:nd
The object is case sensitive.
Be sure that it shouldn't be like "WScript.Shell" or something