Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This Vbscript IS NOT Working and NO ERRORS

Status
Not open for further replies.

TimITFO

MIS
Aug 6, 2008
31
0
0
US
I decided to start a New Post. The other one was getting too big and long.

I'm using a batch file to call this vbscript and I'm not sure whether that's causing any problems. My company has an OU and I don't have access to GPO, I'm only allowed to manage my OU.
Here is my current vbscript, with the server name xxxx out.
It's hard to know why it's acting this way. It's working for only one user and others in the same Group/OU it's not running and no errors.
Basically. I'm trying to accomplish three objectives:
1. Map drives based on Group membership
2. Install Network printers also based on group membership
3. Set Default printers also group membership
4. Welcome Message: Good Morning. Evening
5. Html IE annoucement page.
Mark's Vbscript has been very helpful but I can't make it run?

See the script below..
Thanks,


'===========================================================
'
' NAME: LogonScript.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : ' DATE : 4/10/2003
'
' COMMENT: Enumerates current users' group memberships in given domain.
'
'==========================================================================


ON ERROR RESUME NEXT

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path


Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Synchronizes the time with Server our NTP Server
WSHShell.Run "NET TIME \\xxx/set /y"

'Disconnect any drive mappings as needed.
WSHNetwork.RemoveNetworkDrive "F:"

'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i)
Next

'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300

'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
Case "MCF ADMIN"
WSHNetwork.MapNetworkDrive "r:", "\\xxx\SCAN",True
WSHNetwork.MapNetworkDrive "m:", "\\xxx\cristest",True
WSHNetwork.MapNetworkDrive "p:", "\\xxx\common",True
WSHNetwork.MapNetworkDrive "u:", "\\xxx\PUBLIC",True
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-ADMIN"
WSHNetwork.SetDefaultPrinter "\\xxx\mcf-ADMIN"
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-Xerox"
Case "MCF DISPATCH"
WSHNetwork.MapNetworkDrive "U:", "\\xxx\PUBLIC",True
WSHNetwork.MapNetworkDrive "m:", "\\xxx\cristest",True
WSHNetwork.MapNetworkDrive "p:", "\\xxx\common",True
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-Dispatch"
WSHNetwork.SetDefaultPrinter "\\xxx\mcf-Dispatch"
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-ADMIN"

End Select

'=====================================
Dim tempiepath
tempiepath = "HKCU\Software\Microsoft\Windows\"

WSHShell.RegWrite tempiepath & "ShellNoRoam\MUICache\@inetcplc.dll,-4750","Empty Temporary Internet Files folder when browser is closed","REG_SZ"

WSHShell.RegWrite tempiepath & "CurrentVersion\Internet Settings\Cache\Persistent","0","REG_DWORD"
Set tempiepath = nothing

'=====================================
HKEY_CURRENT_USER = &H80000001
strComputer = WSHNetwork.Computername
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Control Panel\Desktop"
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
ValueName = "PaintDesktopVersion"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue

'=======================================================
' Determine the appropriate greeting for the time of day.
'=======================================================
Dim HourNow, Greeting
HourNow = Hour(Now)
If HourNow >5 And HourNow <12 Then
Greeting = "Good Morning "
Elseif HourNow =>12 And HourNow <16 Then
Greeting = "Good Afternoon "
Else
Greeting = "Good Evening "
End If

Next
'=====================================
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("\\server\Welcome\message.txt") Then
strText = objFSO.OpenTextFile("\\xxx\Welcome\Message.txt", 1).ReadAll
Set objIE = CreateObject("InternetExplorer.Application")
objIE.navigate2 "about:blank" : objIE.width = 350 : objIE.height = 480 : objIE.toolbar = false : objIE.menubar = false : objIE.statusbar = false : objIE.visible = True
objIE.document.write "<font color=blue>"
objIE.document.write "<h1>Important Announcement</h1>"
objIE.document.write strText
objIE.document.write "</font>"
End If

'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing

'Quit the Script
wscript.quit
 
Remove ON ERROR RESUME NEXT and I am sure you might get an error indicating what the problem is.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 

Yes, I did and this is error I'm getting.

Line: 18
Char: 1
Error: The server is not responding.

After changing the server name I got this error.
Line 18
Char: 1
Error: The specified domain either does not exist or could not be contacted
I'm burning out on this script! I really need help.
 
Hi TimITFO

Could you bold line 18 or use the "["Color Red"]" Text "["/Color"]"
tag to highlight line 18.

For example You line 18 Text

My next question is can you ping this server which looks like you're tryingto connect to a DNS host

Remove the quotes from the brackets
 
I had the same message a while ago, coding something very similar and it turned out to be a firewall problem. The calling server could not reach the DC.

I'm guessing line 18 is one of the following two:

Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

Good luck solving this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top