+ Post New Thread
Results 1 to 7 of 7
Scripts Thread, objnetwork or WshNetwork in Coding and Web Development; what is the difference between these "objnetwork" and "wshnetwork" many thanks...
  1. #1

    Join Date
    Jul 2007
    Location
    Lancs
    Posts
    399
    Thank Post
    45
    Thanked 23 Times in 20 Posts
    Rep Power
    18

    Lightbulb objnetwork or WshNetwork

    what is the difference between these
    "objnetwork" and "wshnetwork"

    many thanks

  2. #2

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,019
    Thank Post
    1,365
    Thanked 1,771 Times in 1,193 Posts
    Blog Entries
    22
    Rep Power
    530
    I guess you are trying to map a network drive?

    Its been a long time since I did much programming but aren't these just commonly used variable names used when mapping network drives?

    Essentially theres no difference as they could be called anything.
    So if you are trying to map a network drive you would something like:

    Option Explicit
    Dim objWshNetwork (declare var - could be anything)
    Set objWshNetwork = CreateObject("WScript.Network") (assign var)
    objWshNetwork.MapNetworkDrive("x:","\\Server\Share ")

  3. #3

    Join Date
    Jul 2007
    Location
    Lancs
    Posts
    399
    Thank Post
    45
    Thanked 23 Times in 20 Posts
    Rep Power
    18
    its for printer scripts. I have seen tehse two variations and wondered what is the difference

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,913
    Thank Post
    3,440
    Thanked 1,084 Times in 1,000 Posts
    Rep Power
    370
    what is the difference between these
    "objnetwork" and "wshnetwork"

    many thanks
    As per above they are just variables - you can call it network or mynetwork or whatever you want as long as when you create the object you use the same name for example

    Code:
    Dim Network
    Set Network = CreateObject("WScript.Network")
    
    Network.MapNetworkDrive("x:",\\Server\Share )
    As you can see I have declared Network using the Dim statement, I have then used the Set statement to Set the Network variable so it is equal to the network object which you have to create using CreateObject("WScript.Network")

    Then when you want to use the Network variable to do something you put Network.Property

    Property could be UserName, MapNetworkDrive or whatever property you want to use that is related to the network object as long as its used in the correct way

  5. #5

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    One of the things that can be really confusing in programming in VBScript is the use of variable names; people generally have their own way of naming things but the growth of the internet has meant that most people copy bits of code and edit it - this seems to have lead to certain variables gaining dominance so it looks as if the name matters.

    In a statement like:
    Code:
    set oNet = CreateObject("wscript.network")
    the bit that matters is on the right - you're working with that specific object but you can call it oNet, Network, objNetwork, tom, dick or harry but once you've chosen the name you need to stick with that name while you work with it.

    Code:
    set oFSO=createobject("scripting.filesystemobject")
    set oFile1=ofso.opentextfile("c:\temp\data.txt")
    set oFile2=ofso.opentextfile("c:\temp\data.txt")
    sLine1=oFile1.readline
    wscript.echo sLine
    oFile1.close
    sLine2=oFile2.readline
    oFile2.close
    In the example above, oFile1 and oFile2 are both file objects; they both refer to the same file on disc but they're not the same thing - when I read a line from oFile1 it doesn't do anything to oFile2. When I close oFile1 it doesn't affect oFile2 etc.

  6. #6

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,019
    Thank Post
    1,365
    Thanked 1,771 Times in 1,193 Posts
    Blog Entries
    22
    Rep Power
    530
    Quote Originally Posted by srochford View Post
    One of the things that can be really confusing in programming in VBScript is the use of variable names; people generally have their own way of naming things but the growth of the internet has meant that most people copy bits of code and edit it - this seems to have lead to certain variables gaining dominance so it looks as if the name matters.
    Agreed, it appears that objnetwork and wshnetwork have become commonly used, the misunderstanding is understandable.

  7. #7

    Join Date
    Jul 2010
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    new code for selection from department

    Hello,

    I am kind of new to programming but it looks interesting as i want to make an script for my WMI filter.

    i want to use a WMI filter to look into the department field and if there is a user with department field set to sales than he should get"policy 1"
    and if the user is in production than the user should get "policy 2"
    but i just can not figure out where i can get the object from department field
    can some one help me on the way?

SHARE:
+ Post New Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •