Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
However, if I add a drive mapping on my PC to a network share hosting a
company application, the script runs. As soon as I delete the mapping, the
script fails. Why is this happening? Why does mapping this drive allow the
script to run without errors?
--
Thanks!
If you can post your script, it would also help me troubleshoot for ya. :)
-Corey
I found this at MSDN:
Error code 0x8007007f or error code 0x8007007e
This problem frequently occurs after you upgrade a service pack. After
you upgrade, there appears to be a corrupted file, a missing file, or
a file mismatch.
Workaround for error code 0x8007007f or error code 0x8007007e
To work around this problem, uninstall the service pack that you
installed. Then, reinstall the service pack.
It seems to be and unhandled exception related to "The specified
module could not be found. (Exception from HRESULT: 0x8007007E)"
I don't know whether that helps.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
If Tom's suggestion doesn't help, what is the operating system on the
computer. Also, how do you configure the logon scripts to run - using the
"Logon script" field on the "Profile" tab of ADUC or in a Group Policy.
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
I remarked out the "on error reume next" statements. It still errors. It
errors on line #7. Same error as in original post. I am using Windows XP
SP2. I never installed SP2 as it was built right into the original XP
install disk. Currently, I am just running this .vbs file from my desktop.
Once it works, I plan on creating a GPO to run it at logon. Here is the
script. It is a modified version of one I found on the internet.
Option Explicit
Dim strLogName, bolWriteLog, bolManagePrinters
Dim objNetwork, objDrives, objDict, objComputer, objShell, objFileSystem,
objLogFile, objRootDSE, objTrans
Dim strComputerName, strDomain, strUser, strAdsPath, strNetBIOSDomain,
strDNSDomain, strTemp, strLogPath, i
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objDrives = objNetwork.EnumNetworkDrives
Set objShell = WScript.CreateObject("WScript.Shell")
strLogName = "logfile.log"
bolWriteLog = True
bolManagePrinters = True
strComputerName = objNetwork.ComputerName
strDomain = objNetwork.UserDomain
strUser = objNetwork.UserName
strAdsPath = strDomain & "/" & strUser
strNetBIOSDomain = strDomain
strTemp = objshell.ExpandEnvironmentStrings("%TEMP%")
strLogPath = strTemp & "\" & strLogName
Set objComputer = GetObject("WinNT://" & strNetBIOSDomain & "/" &
strComputerName & ",computer")
Set objFileSystem = WScript.CreateObject("Scripting.FileSystemObject")
If bolWriteLog then ' Initialize log file
'on error resume next
Set objLogFile = objFileSystem.OpenTextFile(strLogPath, 2, True)
writelog "############### Start Login Script ##################"
If not err.number = 0 then
WScript.quit
End if
on error goto 0
End if
If isMember("System Users") or isMember("Metals - System Users") then
'DriveMapper "U:", "\\server-2\share"
End if
writelog "################ End Login Script ###################"
Set objNetwork = Nothing
Set objDrives = Nothing
Set objComputer = Nothing
Set objShell = Nothing
Set objFileSystem = Nothing
Set objLogFile = Nothing
WScript.Quit
'######################### Subs 'n Functions Below #########################
Function IsMember(sGroup)
Dim oDict, oUser, oGroup
If IsEmpty(oDict) Then
Set oDict = CreateObject("Scripting.Dictionary")
oDict.CompareMode = vbTextCompare
Set oUser = GetObject("WinNT://" & strAdsPath & ",user")
For Each oGroup In oUser.Groups
oDict.Add oGroup.Name, "-"
Next
Set oUser = Nothing
End If
IsMember = CBool(oDict.Exists(sGroup))
If IsMember and bolWriteLog then objLogFile.WriteLine(Now() & ": Success:
User is member of " & sGroup)
End Function
sub WriteLog(sEntry)
If bolWriteLog then objLogFile.WriteLine(Now() & ": Log : " & sEntry)
End Sub
Sub DriveMapper(sDrive, sShare)
For i = 0 to objDrives.Count -1 Step 2
If LCase(sDrive) = LCase(objDrives.Item(i)) then
If not LCase(sShare) = LCase(objDrives.Item(i+1)) then
objNetwork.RemoveNetworkDrive sDrive, true, true
Else
If bolWriteLog then objLogFile.WriteLine(Now() & ": Success: Connect
""" & sDrive & """ to share """ & _
sShare & """ (previously connected)")
Exit Sub
End if
End if
Next
'on error resume next
objNetwork.MapNetworkDrive sDrive, sShare
If Err.Number = 0 Then
If bolWriteLog then objLogFile.WriteLine(Now() & ": Success: Connect """
& sDrive & """ to share """ & sShare & """")
Else
If bolWriteLog then objLogFile.WriteLine(Now() & ": Failed: Connect """ &
sDrive & """ to share """ & sShare & """")
End if
on error goto 0
End Sub
"Richard Mueller [MVP]" <rlmuelle...@ameritech.nospam.net> wrote in
message news:uovpc7xg...@TK2MSFTNGP03.phx.gbl...
To get you started:
Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" )
Dim sDSDir : sDSDir = oFS.GetAbsolutePathName( ".\disabledsrvs" )
Dim dicSrvs : Set dicSrvs = CreateObject( "Scripting.Dictionary" )
Dim oRE : Set oRE = New RegExp
oRE.Global = True
oRE.Multiline = True
oRE.Pattern = "^(\w{6})\s\(DISABLED\)"
WScript.Echo "------ Files"
Dim oFile
For Each oFile In oFS.GetFolder( sDSDir ).Files
If "txt" = LCase( oFS.GetExtensionName( oFile.Name ) ) Then
WScript.Echo oFile.Name
Dim sAll : sAll = oFile.OpenAsTextStream().ReadAll
Dim oMTS : Set oMTS = oRE.Execute( sAll )
If 0 < oMTS.Count Then
Dim oMT
For Each oMT In oMTS
WScript.Echo " ", oMT.SubMatches( 0 )
dicSrvs( oMT.SubMatches( 0 ) ) = dicSrvs( oMT.SubMatches( 0 ) ) + 1
Next
End If
End If
Next
WScript.Echo "------ Results"
Dim sKey
For Each sKey In dicSrvs.Keys
If 1 < dicSrvs( sKey ) Then
WScript.Echo sKey, dicSrvs( sKey )
End If
Next
output:
=== fndDisabledSrvs: find disables servers ==
------ Files
monday.txt
SV4213
SV5921
SV4563
tuesday.txt
SV4213
SV5921
SV1000
------ Results
SV4213 2
SV5921 2
=== fndDisabledSrvs: 0 done (00:00:00) ======
Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
msgbox objNetwork.UserDomain
Set objNetwork = Nothing
WScript.quit
The same behavior with this script. If my computer has a U: drive mapping
to a certain share on the network, this script works. If I disconnect the
U: drive, the script fails with the same error.
If the mapping to the share is a different letter than U:, the script FAILS.
By that same token, if U: is mapped to a different share, it fails also. I
need to have the letter U mapped to a certain share for this line....
Set objNetwork = WScript.CreateObject("WScript.Network")
not to error. What the heck is going on here???
"Saucer Man" <sauc...@nospam.com> wrote in message
news:47d67ea7$0$6430$cc2e...@news.uslec.net...
Set objNetwork = CreateObject("WScript.Network")
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
"Saucer Man" <sauc...@nospam.com> wrote in message
news:47d6d9b3$0$25836$cc2e...@news.uslec.net...
"Richard Mueller [MVP]" <rlmuelle...@ameritech.nospam.net> wrote in
message news:ubypg16g...@TK2MSFTNGP02.phx.gbl...