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!

permission denied: 'CreateObject'

Status
Not open for further replies.

BobSakemano

Technical User
Feb 17, 2005
20
0
0
NL


Hey guys,

I get this error when I want to run a script that makes use of the IE object of windows. I’ve simplified the script so that you guys can take a look.

This script is part of a login script for cyrtix servers. The script works when I login on cyrtix via the server. But doesn’t work when I login on cytrix via a different workstation.

Any tips or advice would be appreciated.
 
hmmm,

maybe post the script? [ponder]

Please tell me if I'm wrong I like to learn from my mistakes...
_____________________________________
Feed a man a fish and feed him for a day.
Teach a man to fish and feed him for a lifetime...
 
Here you go:

on error resume next

Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
set ofso=createobject("Scripting.filesystemobject")

strGroups = LCase(join(CurrentUser.MemberOf))
MyUsername = Right(CurrentUser.Name, Len(CurrentUser.Name)-3)

Dim strMappedDrives
Dim strStatus
Dim IE
Dim LogonURL
Dim strUser
Dim WshNetwork
Dim WshShell
Dim varNow


LogonURL = "\\srvr\netlogon\logon.html"

' 1) Display status window using Internet Explorer
Call CreateIE()
strStatus = "Domain Logon Script v1.0" & Date() & " " & Time()
ie.document.all.wstatus.InnerText = strStatus

' 2) Display the User ID
Set WSHNetwork = WScript.CreateObject("WScript.Network")
strUser = ""
While strUser = ""
strUser = WSHNetwork.UserName
Wend
ie.document.all.Msg1.InnerText = strUser


' 4) Map Drives
WshNetwork.RemoveNetworkDrive "O:"
WshNetwork.RemoveNetworkDrive "G:"
WshNetwork.RemoveNetworkDrive "R:"
WshNetwork.RemoveNetworkDrive "W:"
WshNetwork.RemoveNetworkDrive "I:"
WshNetwork.RemoveNetworkDrive "H:"
WshNetwork.RemoveNetworkDrive "L:"
WshNetwork.RemoveNetworkDrive "S:"
WshNetwork.RemoveNetworkDrive "U:"
WshNetwork.RemoveNetworkDrive "H:"


If InStr(strGroups,"cn=algemeen") Then
strStatus = strStatus & vbCRLF & "Mapping drive Q"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "Q:", "\\srvr02\programs$"

strStatus = strStatus & vbCRLF & "Mapping drive F"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "F:", "\\server\sys\public"

strStatus = strStatus & vbCRLF & "Mapping drive G"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "G:", "\\srvr02\programs$\netwerk\rapport"

strStatus = strStatus & vbCRLF & "Mapping drive R"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "R:", "\\srvr02\programs$\registr\nieuw"

strStatus = strStatus & vbCRLF & "Mapping drive W"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "W:", "\\srvr02\programs$\wpdos\wpver51"

strStatus = strStatus & vbCRLF & "Mapping drive H"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "H:", "\\srvr02\data$"
End If

If InStr(strGroups, "cn=citrix") Then
strStatus = strStatus & vbCRLF & "Mapping drive O"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "O:", "\\srvr02\programs$\netwerk\bin\"

strStatus = strStatus & vbCRLF & "Mapping drive L"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "L:", "\\srvr02\groups$\jonger"
End if

If InStr(strGroups, "cn=bedrijfsbureau") Then
strStatus = strStatus & vbCRLF & "Mapping drive U"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "U:", "\\srvr02\groups$\bedrijfsbureau"
End if

If InStr(strGroups, "cn=administratie") Then
strStatus = strStatus & vbCRLF & "Mapping drive S"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "S:", "\\srvr02\groups$\adminis"
End if

If InStr(strGroups, "cn=financien") Then
strStatus = strStatus & vbCRLF & "Mapping drive L"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "L:", "\\srvr02\programs$\bin\"
End if


If InStr(strGroups, "cn=huizingalaan") Then
strStatus = strStatus & vbCRLF & "Mapping drive I"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "I:", "\\srvr02\programs$\netwerk\data\"
End if

If InStr(strGroups, "cn=systeembeheer") Then
strStatus = strStatus & vbCRLF & "Mapping drive S"
ie.document.all.wstatus.InnerText = strStatus
MapDrive "S:", "\\srvr02\data$"
End if



If ie.document.all.showCMD.checked then
' display the script - run and pause
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /k background.cmd", 1, true

Else
'Hide script - run synchronously
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "background.cmd", 0, false
End if

' 6) Nearly done - cleanup

strStatus = strStatus & vbCRLF & "Network Logon Complete..."
ie.document.all.wstatus.InnerText = strStatus

' Close IE status window
If ie.document.all.holdit.checked then
ie.quit()
End if

' --- Subroutines -----------------

Sub MapDrive(strDrive,strShare)

On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, strShare

If Err.Number Then

WSHNetwork.RemoveNetworkDrive strDrive
WSHNetwork.MapNetworkDrive strDrive, strShare

End If

strMappedDrives = strMappedDrives & strDrive & " "
ie.document.all.Msg2.InnerText = strMappedDrives

End Sub

Sub CreateIE()

On Error Resume Next
Set IE = CreateObject("InternetExplorer.Application")
With IE
.navigate LogonURL
.resizable=0
.height=445
.width=440
.menubar=0
.toolbar=0
.statusBar=0
.visible=1
End With
' wait for page to load
while ie.Busy: wend
' Do while ie.Busy
' wait for page to load
' Wscript.Sleep 100
'Loop

End Sub

' --- End of logon.vbs -----------------------
 
Do you also get a linenumber in the error to see which "createobject" is giving the error?

Please tell me if I'm wrong I like to learn from my mistakes...
_____________________________________
Feed a man a fish and feed him for a day.
Teach a man to fish and feed him for a lifetime...
 
Hello Bobsakemano!

If you're getting a permission denied error, then I'm guessing it's probably from the navigate statement. If it's not giving you a specific line for the error, one way to tell is to put a message box before and after the navigate statement.

If that truely is where the error is occuring, then it's quite obvious that the ID that the script is running under does not have access to what you're navigating to (in your case it's "\\srvr\netlogon\logon.html").

Check the permissions of that HTML document. If you run the script as you (you double click to run, or specify your ID in Windows scheduler), then check to see what permissions your ID has. If you are running the script as system and you are reaching across servers, then that presents a whole new problem (we've run into that here). The system ID only has authority on the workstation it's running on. If you want to reach across servers, then you'll need to create a process ID that has the neccessary privileges on both servers.

If I'm way off here, provide a little more detail and we'll see what we can do!

Good luck

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top