Re: Help with Objet required




"Juanjillo" <juanjillo_____NOSPAM___@xxxxxxxxx> wrote in message
news:mn.9c297d857f379589.56404@xxxxxxxxxxxx
Richard Mueller [MVP] comentaba el 19/05/2008:
Juanjillo wrote:


I have this script in example1.vbs:

Dim objshell, objnetwotk
Set objshell = WScript.CreateObject("Wscript.Shell")
Set objnetwork = WScript.CreateObject("Wscript.Network")


Dim vdom, vuser
Set vdom = objnetwork.UserDomain
Set vuser = objnetwork.UserName
wscript.echo "Welcome to the domain: " & vdom & ", " & vuser & "."

when i execute this command with csript example1.vbs y have this
response.
Object is requied [string: "Mydomainname"]


Don't use "set" when you assign values to the string variables. Use:

vdom = objnetwork.UserDomain
Set vuser = objnetwork.UserName

Only use "Set" to assign object references, like objNetwork.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net

Thanks a lot
I´m newbie wit this :D

--
Agures


No problem. The "Set" keyword takes getting used to. To learn more about
scripting for administration of AD networks I recommend "Microsoft Windows
2000 Scripting Guide". I like the hard copy text, but it is also available
online at:

http://www.microsoft.com/technet/scriptcenter/guide/sagsas_overview.mspx?mfr=true

The first few chapters in Part 1 explain the basics of WSH, VBScript, ADSI,
etc. For example, the Set statement (and your error) are explained here:

http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_ebqs.mspx

You can also learn from the scripts in the Technet Script Center:

http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Help with Objet required
    ... Dim vdom, vuser ... Set vuser = objnetwork.UserName ... Only use "Set" to assign object references, like objNetwork. ... MVP Directory Services ...
    (microsoft.public.scripting.wsh)
  • Re: Help with Objet required
    ... Dim objshell, objnetwotk ... Dim vdom, vuser ... Set vuser = objnetwork.UserName ... Only use "Set" to assign object references, like objNetwork. ...
    (microsoft.public.scripting.wsh)
  • Re: Help with Login Script.
    ... If (strComputerName = "MyServer") Then ... Otherwise, the script continues. ... bind to objNetwork before I use the object to retrieve the computer name. ... Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3, ...
    (microsoft.public.windows.server.scripting)
  • Re: VB Script to Copy File to Profile
    ... Dim objFSO, objNetwork, strLogonid, strUserName ... Also, it's likely that strLogonid and strUserName refer to the same thing, ... Because the script uses "Option Explicit", ...
    (microsoft.public.scripting.vbscript)
  • Re: Variable is undefined: WSHNetwork
    ... following script - it fails on the last line. ... Set objNetwork = CreateObject ... objNetwork.AddWindowsPrinterConnection strUNCPrinter ...
    (microsoft.public.scripting.wsh)

Loading