|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Script doesn't work through Remote Desktop / W2K3 Server
This script, when run locally, works fine:
Set objNet = CreateObject("WScript.NetWork") Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) WScript.Echo objUser.Name But when we use remote desktop connection to connect to our terminal server, then run it off a shared drive there, it returns nothing. Anyone know why? It's hard to give suggestions without more info. It could be name resolution,
network connectivity, or permissions. Turn on the error handler and post the output: On Error GoTo 0 Set objNet = CreateObject("WScript.NetWork") Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) WScript.Echo objUser.Name "MMMMM" <noem***@replytogroup.com> wrote in message then run it off a shared drive there, it returnsnews:O9JLofrlFHA.3568@tk2msftngp13.phx.gbl... > This script, when run locally, works fine: > > Set objNet = CreateObject("WScript.NetWork") > Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) > WScript.Echo objUser.Name > > But when we use remote desktop connection to connect to our terminal server, Show quote > nothing. Anyone know why? > > Well I took an excerpt from a alrger script... and it turns out that I get:
Invalid procedure Call or Argument: "Left" as I am taking a part of a string later on... Hmmm... this is W2K3, do I need to install some scripting componet to support "Left" ? I thought that was a basic part of Windows Scripting Host? Thanks for any help. Show quote "Marty List" <use***@optimumx.com> wrote in message news:O79LFHtlFHA.360@TK2MSFTNGP09.phx.gbl... > > It's hard to give suggestions without more info. It could be name resolution, > network connectivity, or permissions. Turn on the error handler and post the > output: > > On Error GoTo 0 > Set objNet = CreateObject("WScript.NetWork") > Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) > WScript.Echo objUser.Name > > > > "MMMMM" <noem***@replytogroup.com> wrote in message > news:O9JLofrlFHA.3568@tk2msftngp13.phx.gbl... >> This script, when run locally, works fine: >> >> Set objNet = CreateObject("WScript.NetWork") >> Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) >> WScript.Echo objUser.Name >> >> But when we use remote desktop connection to connect to our terminal server, > then run it off a shared drive there, it returns >> nothing. Anyone know why? >> >> > > Your script is using the VBScript engine, and it is being executed by the
Windows Script Host. The Left function is built-in to VBScript, here's the syntax: http://msdn.microsoft.com/library/en-us/script56/html/vsfctLeft.asp "MMMMM" <noem***@replytogroup.com> wrote in message to install some scripting componet to support "Left" ?news:uESQPHulFHA.2484@TK2MSFTNGP15.phx.gbl... > Well I took an excerpt from a alrger script... and it turns out that I get: > > Invalid procedure Call or Argument: "Left" > > as I am taking a part of a string later on... Hmmm... this is W2K3, do I need Show quote > I thought that was a basic part of Windows Scripting Host? Thanks for any help. > > > "Marty List" <use***@optimumx.com> wrote in message news:O79LFHtlFHA.360@TK2MSFTNGP09.phx.gbl... > > > > It's hard to give suggestions without more info. It could be name resolution, > > network connectivity, or permissions. Turn on the error handler and post the > > output: > > > > On Error GoTo 0 > > Set objNet = CreateObject("WScript.NetWork") > > Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) > > WScript.Echo objUser.Name > > > > > > > > "MMMMM" <noem***@replytogroup.com> wrote in message > > news:O9JLofrlFHA.3568@tk2msftngp13.phx.gbl... > >> This script, when run locally, works fine: > >> > >> Set objNet = CreateObject("WScript.NetWork") > >> Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) > >> WScript.Echo objUser.Name > >> > >> But when we use remote desktop connection to connect to our terminal server, > > then run it off a shared drive there, it returns > >> nothing. Anyone know why? > >> > >> > > > > > > OK I'm an idiot.
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48) For Each objItem in colItems If objItem.DNSDomain <> "" Then Domain = objItem.DNSDomain End If Next I try to use Left() on the Domain variable which is nothing... so now I have to figure out why the above snippet won't return anything. Show quote "MMMMM" <noem***@replytogroup.com> wrote in message news:uESQPHulFHA.2484@TK2MSFTNGP15.phx.gbl... > Well I took an excerpt from a alrger script... and it turns out that I get: > > Invalid procedure Call or Argument: "Left" > > as I am taking a part of a string later on... Hmmm... this is W2K3, do I need to install some scripting componet to support "Left" > ? I thought that was a basic part of Windows Scripting Host? Thanks for any help. > > > "Marty List" <use***@optimumx.com> wrote in message news:O79LFHtlFHA.360@TK2MSFTNGP09.phx.gbl... >> >> It's hard to give suggestions without more info. It could be name resolution, >> network connectivity, or permissions. Turn on the error handler and post the >> output: >> >> On Error GoTo 0 >> Set objNet = CreateObject("WScript.NetWork") >> Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) >> WScript.Echo objUser.Name >> >> >> >> "MMMMM" <noem***@replytogroup.com> wrote in message >> news:O9JLofrlFHA.3568@tk2msftngp13.phx.gbl... >>> This script, when run locally, works fine: >>> >>> Set objNet = CreateObject("WScript.NetWork") >>> Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) >>> WScript.Echo objUser.Name >>> >>> But when we use remote desktop connection to connect to our terminal server, >> then run it off a shared drive there, it returns >>> nothing. Anyone know why? >>> >>> >> >> > > Always "initialize" your variables before trying to use them. Try setting
Domain = "" before using it. Better yet - always always always use "Option Explicit" as the first line of every script you write. Try this: Option Explicit Dim strComputer, strDomain Dim objWMIService, colItems, objItem strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from " & _ "Win32_NetworkAdapterConfiguration", , 48) For Each objItem in colItems WScript.Echo objItem.Description strDomain = "" If objItem.DNSDomain <> "" Then strDomain = objItem.DNSDomain WScript.Echo vbTab & strDomain End If Next Show quote "MMMMM" <noem***@replytogroup.com> wrote in message to figure out why the above snippet won't returnnews:ehFiuMulFHA.2916@TK2MSFTNGP14.phx.gbl... > OK I'm an idiot. > > strComputer = "." > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") > Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48) > For Each objItem in colItems > > > If objItem.DNSDomain <> "" Then > Domain = objItem.DNSDomain > End If > > Next > > > > I try to use Left() on the Domain variable which is nothing... so now I have > anything. need to install some scripting componet to support "Left"> > > "MMMMM" <noem***@replytogroup.com> wrote in message news:uESQPHulFHA.2484@TK2MSFTNGP15.phx.gbl... > > Well I took an excerpt from a alrger script... and it turns out that I get: > > > > Invalid procedure Call or Argument: "Left" > > > > as I am taking a part of a string later on... Hmmm... this is W2K3, do I Show quote > > ? I thought that was a basic part of Windows Scripting Host? Thanks for any help. > > > > > > "Marty List" <use***@optimumx.com> wrote in message news:O79LFHtlFHA.360@TK2MSFTNGP09.phx.gbl... > >> > >> It's hard to give suggestions without more info. It could be name resolution, > >> network connectivity, or permissions. Turn on the error handler and post the > >> output: > >> > >> On Error GoTo 0 > >> Set objNet = CreateObject("WScript.NetWork") > >> Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) > >> WScript.Echo objUser.Name > >> > >> > >> > >> "MMMMM" <noem***@replytogroup.com> wrote in message > >> news:O9JLofrlFHA.3568@tk2msftngp13.phx.gbl... > >>> This script, when run locally, works fine: > >>> > >>> Set objNet = CreateObject("WScript.NetWork") > >>> Set objUser = GetObject("WinNT://mydomain.com/" & objNet.UserName ) > >>> WScript.Echo objUser.Name > >>> > >>> But when we use remote desktop connection to connect to our terminal server, > >> then run it off a shared drive there, it returns > >>> nothing. Anyone know why? > >>> > >>> > >> > >> > > > > > > |
|||||||||||||||||||||||