Not able to read file on remote server.

Author Message
enjoyabhi

  • Total Posts : 13
  • Scores: 0
  • Reward points : 0
  • Joined: 10/11/2010
  • Status: offline
Not able to read file on remote server. Tuesday, December 13, 2011 2:10 PM (permalink)
0
I have a script which make use WMI remote login  and  takes Global path from IIS of remote server and then will go to that location and then will look for some specific string in web.config . Now the problem here is - If I am running this script for a remote server it gives me Access denied error but once I go to the path manually from my system and after that when I run this script it works perfectly ..
e.g.
I have a server "abc" and location of web.config is" D:\websites\abhi\" then using Wmi I am trying to read this path - \\abc\D$\websites\Abhi\web.config but it throws access denied error . And when I go to start ->Run and go to \\abc\D$\  . and then if I am running this script it works fine after that.
Note- After accessing the path manually it never gives error for that particular server.
 
Code -
WbemAuthenticationLevelPktPrivacy=6
Set WSHNetwork = CreateObject("WScript.Network" )
astrComputer = frmform1.Optionchooserver.value
'Msgbox"Vmserver: " &astrcomputer
'Set objWMIService = GetObject _
'    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
'        & astrComputer & "\root\microsoftiisv2")
strUser="us\svc.cwpcron"
strPassword="MatchB0x"
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objwbemLocator.ConnectServer _
    (astrComputer, "\root\microsoftiisv2", strUser, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebVirtualDirSetting")
For Each objItem in colItems
   
   
  
'Msgbox "path for global: " &objitem.path
    configParm11=objitem.path&"\web.config"
configParm11=(Mid(ConfigParm11,3,75))
configParm11="\\"&astrcomputer&"\d$"&configParm11
    exit for
     
Next
'Adding WMI second time
'#####
MsgBox "ConfigParm11="&ConfigParm11
'Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService2 = objwbemLocator.ConnectServer _
    (astrComputer, "\root\cimv2", strUser, strPassword)
objWMIService2.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
Set colFileList = objWMIService2.ExecQuery _
    ("ASSOCIATORS OF {Win32_Directory.Name='" & objitem.path & "'} Where " _
        & "ResultClass = CIM_DataFile")
        'MsgBox "configParm11"&configParm11
'#######3
For Each objFileItem In colFileList
MsgBox ""
Configparm12=ConfigParm11
'configParm11="\\nvm0543pdv.us.global.schwab.com\D$\WebSites\CWP\Global\v12.1.0-INT08\Public\web.config"
'sgBox "configParm11"&configParm11
Set objFS=CreateObject("Scripting.FileSystemObject")
Set Revconfig=objFS.opentextfile(configparm12,1)    '#####Access denied error 'comes for this line"
Revconfig=Revconfig.ReadAll
msgbox "hi"&Revconfig
next
 
#1
    wenbibi

    • Total Posts : 11
    • Scores: 0
    • Reward points : 0
    • Joined: 12/18/2011
    • Status: offline
    Re:Not able to read file on remote server. Sunday, December 18, 2011 4:26 PM (permalink)
    0

    The love world is big, which can hold hundreds of disappointments; the love world is small which is crowded even with three people inside. Toronto Escort
    To the world you may be one person, but to one person you may be the world. Toronto Escorts
    Don’t waste your time on a man/woman, who isn’t willing to waste their time on you. Toronto Asian Escorts Don’t try so hard, the best things come when you least expect them to. Toronto Asian Escort
    Maybe God wants us to meet a few wrong people before meeting the right one, so that when we finally meet the person, we will know how to be grateful.
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9