Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error 8007007E WScript.Network Wscript.CreateObject

1,241 views
Skip to first unread message

Saucer Man

unread,
Mar 10, 2008, 2:12:25 PM3/10/08
to
I am getting an error in my .vbs script. The error is "Could not create
object named "WScript.Network". The code is 8007007E. The source is
WScript.CreateObject. The program errors on the "Set" line of code below.

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!


Corey Thomas - MCSE/MCSA/MCDBA

unread,
Mar 10, 2008, 4:29:09 PM3/10/08
to
Remove any "on error resume next" lines, then run the script to see exactly
what the error and line number is.

If you can post your script, it would also help me troubleshoot for ya. :)

-Corey

Tom Lavedas

unread,
Mar 10, 2008, 4:38:38 PM3/10/08
to

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/

Richard Mueller [MVP]

unread,
Mar 10, 2008, 10:23:08 PM3/10/08
to

"Tom Lavedas" <tglb...@cox.net> wrote in message
news:4d07ee89-1ba0-4909...@u69g2000hse.googlegroups.com...

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
--


Saucer Man

unread,
Mar 11, 2008, 8:44:24 AM3/11/08
to
Thanks Corey, Tom, and Richard.

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...

ekkehard.horner

unread,
Mar 11, 2008, 8:45:18 AM3/11/08
to
ekkehard.horner schrieb:
This message wasn't send by me; I can't explain how this could happen,
but I apologize for any inconvenience caused by this.

ekkehard.horner

unread,
Mar 11, 2008, 8:46:20 AM3/11/08
to
Jrex7 schrieb:
> I am trying to create a script that will read multiple text files inside a
> specific folder and finds the device names that appears on more than one
> file, then display in an excel sheet the device names and the number of times
> it found the device name.
>
> Details - I run a daily repot that shows the state of specific devices (
> Device name is always the first six characters in a line and the state of the
> device is always at the end of the line in between parethesis (state)). I
> then export the report as a text file with the name of the day (mon.txt,
> tue.txt etc. etc. ) to a folder in my computer. Report files show all Devices
> with their repective state. Devices only show once in a report.
> What I am trying to do is create a script that I will run on friday that
> will check all the text files (monday - friday) then show the devices that
> were shown in more than one file with a specific state. I will always look
> for the same specific state i,e "(disabled)"
>
> Any help with this script will be appreciated.

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) ======

Saucer Man

unread,
Mar 11, 2008, 3:12:55 PM3/11/08
to
Let's make this even simpler. I created a very small script.

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...

Richard Mueller [MVP]

unread,
Mar 11, 2008, 3:23:15 PM3/11/08
to
What happens if you use the following?

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...

Saucer Man

unread,
Mar 12, 2008, 12:51:41 PM3/12/08
to
I get an error when I try that also. However, I downloaded the latest
Windows Scripting Host for XP/2000 and it now works. Strange but I'm happy
it works. I wonder how many workstations will need this installed now.
Thanks for the help!

"Richard Mueller [MVP]" <rlmuelle...@ameritech.nospam.net> wrote in

message news:ubypg16g...@TK2MSFTNGP02.phx.gbl...

0 new messages