locked
New Computer and VB Script Not Populating Fields Correctly RRS feed

  • Question

  • I recently inherited some computers that populate login details using VBS.  However, I've upgraded the hardware (still the keeping same installed Windows on there) and the auto population is not populating the login name right.  I know very little about VBS, and I've asked the person who wrote the software, and they said they can't remember how they did the scripting as it was years ago. 

    There is no IP change, or PC name change. The complete script is below with passwords changed, and I'm on the RDG network:

    'WScript.Sleep(10000) 

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Return = Wshshell.Run ("""c:\windows\system32\wbusy.exe""" & " ""Steam Games Launcher"" ""Steam Loading. Please wait..."" /marquee" ,1,FALSE)


    Dim Num
    Dim GFD
    Dim RDG
    Dim Subnet
    Dim Login
    Dim Pass
    Dim SteamPath
    Dim ErrorLevel
    Dim ObjFSO

    num=100
    subnet=0

    Set objWMIService = GetObject("winmgmts:")
    Set colNicConfig = objWMIService.ExecQuery("SELECT * FROM " & "Win32_NetworkAdapterConfiguration")
    ' WHERE DHCPEnabled = True")
      For Each objNicConfig In colNicConfig
        if Subnet=0 then
    '     WScript.Echo "Network Adapter: " & objNicConfig.Index
    '     WScript.Echo "  IP Address(es):"
          If Not IsNull(objNicConfig.IPAddress) Then
            For Each strIPAddress In objNicConfig.IPAddress
    '          WScript.Echo "    " & strIPAddress
              GFD = InStr(strIPAddress, "10.1.0.")
              RDG = InStr(strIPAddress, "10.2.0.")
              SJW = InStr(strIPAddress, "10.5.0.")
              if GFD>0 then Subnet=1 end if
              if RDG>0 then Subnet=1 end if
              if SJW>0 then Subnet=1 end if
       
              if Subnet>0 then
    '            wscript.echo "GFD:" & GFD & " RDG:" & RDG & " SJW:" & SJW
                if instr(right(strIPAddress,2),".")>0 then
                  Num=right(strIPAddress,1)
                  else
                  Num=right(strIPAddress,2)
            end if
                Exit For
              end if

              if subnet>0 then Exit For end if
            Next
          End If
        End if  
      Next

    If GFD = 1 Then
      SteamPath = "C:\Program Files\Steam\Steam.exe"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists("C:\Program Files\Steam\clientregistry.blob") Then objFSO.DeleteFile("C:\Program Files\Steam\clientregistry.blob")
      If num >=10 then
        login = "uk0141pc"
        pass = "123"
        num=num + 10
      else
        login = "QGuildfordpc0"
        pass = "123"
      end if
    end if

    If RDG = 1 Then
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If num <=5 then
        If objFSO.FileExists("C:\Program Files\Valve\Steam\clientregistry.blob") Then objFSO.DeleteFile("C:\Program Files\Valve\Steam\clientregistry.blob")
        SteamPath = "C:\Program Files\Valve\Steam\Steam.exe"
        login = "uk0141pc"
        pass = "123"
        num=num + 10
      elseif num <= 12 then
        If objFSO.FileExists("C:\Program Files\Valve\Steam\clientregistry.blob") Then objFSO.DeleteFile("C:\Program Files\Valve\Steam\clientregistry.blob")
        SteamPath = "C:\Program Files\Valve\Steam\Steam.exe"
        login = "uk0141pc"
        pass = "123"
        num=num + 15
      elseIf num <= 17 then
        If objFSO.FileExists("C:\Program Files\Valve\Steam\clientregistry.blob") Then objFSO.DeleteFile("C:\Program Files\Valve\Steam\clientregistry.blob")
        SteamPath = "C:\Program Files\Valve\Steam\Steam.exe"
        login = "uk0141pc"
        pass = "123"
        num=num + 3
      elseif num > 20 then
        If objFSO.FileExists("C:\Program Files\Valve\Steam\clientregistry.blob") Then objFSO.DeleteFile("C:\Program Files\Valve\Steam\clientregistry.blob")
        SteamPath = "C:\Program Files\Valve\Steam\Steam.exe"
        login = "uk0141pc"
        pass = "123"
      end if
    end if

    If SJW = 1 Then
      SteamPath = "C:\Program Files(x86)\Steam\Steam.exe"
      If num <2 then
        login = "123"
        pass = "123"
        num=nul
      else
        login = "QGuildfordPC0"
        pass = "123"
        num=nul
      end if
    end if

    Command = """" & SteamPath & """" & " -login " & login & Num & " " & pass
    'Wscript.echo Command
    if subnet >0 then errorlevel = WshShell.Run(Command,4,FALSE) end if
    'wscript.echo "errorlevel =" & ErrorLevel
    WScript.sleep 25000
    Return = Wshshell.Run ("""c:\windows\system32\wbusy.exe""" & " ""Steam Games Launcher"" /stop" ,1,FALSE)

    Tuesday, September 25, 2018 1:05 PM

All replies