Computing.Net > Forums > Windows 2000 > VBS script on Domain controller

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBS script on Domain controller

Reply to Message Icon

Name: t-bone
Date: September 25, 2007 at 17:24:18 Pacific
OS: win 2000
CPU/Ram: 600/256
Product: asus
Comment:

I have a Win2000 domain controller. I have a Group Policy that runs at logon for each user at the domain level. When the users logon to there client computer the script succesfully runs (I am just adding a network printer thats on the domain controller for the users to use).
When i log onto the domain controller as administrator, the script brings up an error, here is the error:

Error: The filename, directory name, or volume label syntax is incorrect.

here is the code in the .vbs file:
'Connect a network printer

Option Explicit

Dim strPrinterPath, WshNetwork
strPrinterPath = "\\dc-svr\Epson1270"

Set WshNetwork = createobject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection(strPrinterPath)
WScript.Quit

The error is pointing to this line:
WshNetwork.AddWindowsPrinterConnection(strPrinterPath)

why is this line causing a Windows Script Host error on the Domain Controller when I logon as administrator? Is it because the printer is already shared and installed on this Domain Controller?



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: September 25, 2007 at 18:24:25 Pacific
Reply:

Well, I could do a handful of trials on my home (non-AD'ed) PC, and a bit of research to find out exactly what is happening, and why, but I'm not at home.

So instead, I'm just going to tell you to insert the following line just before the WshNetwork.AddWindowsPrinterConnection(strPrinterPath) line:
If WshNetwork.ComputerName = "DC-SVR" Then WScript.Quit

Optionally, you could just add this as your second line:
On Error Resume Next
That won't fix your problem, but it will make the script be quiet.


0

Response Number 2
Name: t-bone
Date: September 26, 2007 at 11:49:22 Pacific
Reply:

I put that if.. else statement in and the error did not pop up on the domain controller called "dc-svr".

that solved the pop up run time error, but do you know why it was happening on this computer and not on the client computers?

When i put the name of the server in lower case "dc-svr" the if statement did not work,but once i put the name of the server in uppercase then the if statement worked, why uppercase over lowercase?

strPrinterPath = "\\dc-svr\Epson1270"

Set WshNetwork = createobject("WScript.Network")

if WshNetwork.ComputerName = "DC-SVR" then
WScript.Echo wshnetwork.ComputerName & " is equal"
WScript.Quit
else
'wscript.echo wshnetwork.computername
WshNetwork.AddWindowsPrinterConnection strPrinterPath
end if

WScript.Echo "Check the printers folder for : " & strPrinterPath

WScript.Quit


0

Response Number 3
Name: Razor2.3
Date: September 26, 2007 at 17:30:53 Pacific
Reply:

do you know why it was happening on this computer and not on the client computers?
No, I do not. I assume it has something to do with some limitation about connecting to your own network printer share, or some sort of naming conflict.

uppercase over lowercase?
Because the comparison is case sensitive, and the computer name is always uppercase. If you're worried about case sensitivity, you can either force the input to be a certain case (via UCase(str)/LCase(str)), or do something like If InStr(1, WshNetwork.ComputerName, "DC-SVR", 1) Then and that'll be case insensitive.


0

Response Number 4
Name: t-bone
Date: September 27, 2007 at 10:11:00 Pacific
Reply:

Just wanted to see if your reasoning on why the dc-svr was having the run time pop up error was the same reasoning as mine, and it was.

yeah, I know all about that ucase( ), lcase( ) vb functions.

thanks.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: VBS script on Domain controller

VPN on domain controller www.computing.net/answers/windows-2000/vpn-on-domain-controller/38386.html

Local Admin on Domain Controller? www.computing.net/answers/windows-2000/local-admin-on-domain-controller/47421.html

change acl on domain controller www.computing.net/answers/windows-2000/change-acl-on-domain-controller/61363.html