Permission Denied Error

Author Message
morpheus83uk

  • Total Posts : 738
  • Scores: 0
  • Reward points : 0
  • Joined: 8/21/2006
  • Status: offline
Permission Denied Error Thursday, December 08, 2011 11:32 PM (permalink)
0
Hello,
I have the following script which works fine however its being run as a group policy now when the first machine runs it everything works fine however the next machine comes along and gets a permission denied error on the following line:
 
The Error Line:
 
Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Error.txt", 8, true)
    objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
The Script:
<code>
'On Error Resume Next
TxtEncryptionChecked = "C:\EncryptionChecked4.txt"
'Set Paths of Variables - Local files
strDirectory = "C:\DcppDiskInfo\"
strFileEncrypted = "DcPPDiskInfo.txt"
strFileUnencrypted = "DcPPError.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 8

'Find Hostname
 Set objNTInfo = CreateObject("WinNTSystemInfo")
 varHostname = lcase(objNTInfo.ComputerName)
'********************************
Set WshNetwork = CreateObject("WScript.Network")
LogonName = WshNetwork.UserName
'ThisHostName = WshNetwork.ComputerName
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
   
PCMAKE = objComputer.Manufacturer
PCMODEL = objcomputer.Model
Next
'********************************

If objFSO.FileExists(TxtEncryptionChecked) Then
wscript.quit
else if objFSO.FileExists(strDirectory & strFileEncrypted) Then
    Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Encrypted.txt",8, true)
    objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
    objTextFile.Close
    objFSO.CopyFile "\\server1\Share\EncryptionChecked4.txt", "C:\SESins\EncryptionChecked4.txt"
 
else If objFSO.FileExists(strDirectory & strFileUnencrypted) Then
Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Error.txt", 8, true)
    objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
    objTextFile.Close
Else
    Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\No Result.txt",8, true)
    objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
    objTextFile.Close
End If
end If
End If
</code>
 
Does anyone know why this is happening? Its been working for a good year and now we have just started to recieve this error? I am thinking because the file is not closing however its written in to close the file...
 
Any idea's?
 
Many Thanks
 
James
 
#1
    Wakawaka

    • Total Posts : 456
    • Scores: 23
    • Reward points : 0
    • Joined: 8/27/2009
    • Status: offline
    Re:Permission Denied Error Friday, December 09, 2011 1:06 AM (permalink)
    0
    At what line does the script error out?  People often have issues closing a file and then manipulating it quickly afterward, especially if it is a remote for. 
     
    You could also check the event logs on the computer the script executed on to see if the OS wrote a specific event telling the reason for the failure.
     
    #2
      morpheus83uk

      • Total Posts : 738
      • Scores: 0
      • Reward points : 0
      • Joined: 8/21/2006
      • Status: offline
      Re:Permission Denied Error Friday, December 09, 2011 2:19 AM (permalink)
      0
      It errors on either of the following lines:
       
      Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Error.txt", 8, true)
          objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
       
      The script its self gives me the [ermission denied error and I am unable to find anything in the event logs :(
       
       
      #3
        Wakawaka

        • Total Posts : 456
        • Scores: 23
        • Reward points : 0
        • Joined: 8/27/2009
        • Status: offline
        Re:Permission Denied Error Friday, December 09, 2011 2:55 PM (permalink)
        0
        Have you tried adding a pause to the script to see if it alleviates the issue?
         
        #4
          59cobalt

          • Total Posts : 979
          • Scores: 91
          • Reward points : 0
          • Joined: 7/17/2011
          • Status: offline
          Re:Permission Denied Error Saturday, December 10, 2011 2:13 AM (permalink)
          0
          morpheus83uk
          I have the following script which works fine however its being run as a group policy now when the first machine runs it everything works fine however the next machine comes along and gets a permission denied error on the following line:

          The Error Line:

          Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Error.txt", 8, true)
          objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
          Do both share and file ACLs on \\server1\Share grant write-access to the user running the script? Is the file perhaps opened/locked by some other user?
           
          #5
            morpheus83uk

            • Total Posts : 738
            • Scores: 0
            • Reward points : 0
            • Joined: 8/21/2006
            • Status: offline
            Re:Permission Denied Error Monday, December 12, 2011 2:05 AM (permalink)
            0
            Hello,
             
            I have not added in a pause as I have just paused for hours and I still get the same issue....
             
            In regards to the permissions any machine can get to it and create and write to the file if that same PC tries again it will error so it is not a permissions issue its like the file is in use somewhere but its told to close the file.....
             
            Any other suggestions?
             
            Many Thanks
             
            James
             
            #6
              59cobalt

              • Total Posts : 979
              • Scores: 91
              • Reward points : 0
              • Joined: 7/17/2011
              • Status: offline
              Re:Permission Denied Error Monday, December 12, 2011 7:12 AM (permalink)
              0
              Repeating my second question: is the file perhaps opened/locked by someone?
               
              #7
                morpheus83uk

                • Total Posts : 738
                • Scores: 0
                • Reward points : 0
                • Joined: 8/21/2006
                • Status: offline
                Re:Permission Denied Error Monday, December 12, 2011 10:04 PM (permalink)
                0
                Well this is the thing... I presume it is open by the machine which last wrote to it however the script closes it...
                 
                My question is with it running Group Policy would this effect it? and if so how could I get around this issue?
                 
                Many Thanks
                 
                James
                 
                #8
                  59cobalt

                  • Total Posts : 979
                  • Scores: 91
                  • Reward points : 0
                  • Joined: 7/17/2011
                  • Status: offline
                  Re:Permission Denied Error Monday, December 12, 2011 10:13 PM (permalink)
                  0
                  Instead of presuming, why don't you, like, actually check it?
                   
                  #9
                    morpheus83uk

                    • Total Posts : 738
                    • Scores: 0
                    • Reward points : 0
                    • Joined: 8/21/2006
                    • Status: offline
                    Re:Permission Denied Error Tuesday, December 13, 2011 2:29 AM (permalink)
                    0
                    How would I do that? I can open it and close it and save stuff inside it but I still get the same error....
                     
                    #10
                      59cobalt

                      • Total Posts : 979
                      • Scores: 91
                      • Reward points : 0
                      • Joined: 7/17/2011
                      • Status: offline
                      Re:Permission Denied Error Tuesday, December 13, 2011 7:34 AM (permalink)
                      0
                      Files opened from shares: http://www.support.tabs3.com/main/R10028.htm
                      Files opened locally: http://technet.microsoft..../sysinternals/bb896653 (Find > Find Handle or DLL...)
                       
                      #11
                        wenbibi

                        • Total Posts : 11
                        • Scores: 0
                        • Reward points : 0
                        • Joined: 12/18/2011
                        • Status: offline
                        Re:Permission Denied Error Sunday, December 18, 2011 4:27 PM (permalink)
                        0
                        OH~NO
                        very body wants to succeed. But when it comes to the question that which factor leads to success, opportunity or hard-work, different people will offer different answers. San Francisco Escort 
                        Some people think that opportunity is the first factor leading to success. They hold the idea, as a proverb saying, “Man proposes, god disposes”. San Francisco Escorts Because almost all successful people have good luck and have caught their valuable opportunities, they believe that opportunity is a leading condition of the success. San Francisco Asian Escort If seizes and makes the best use of opportunity available, one can succeed surely. In summary, to them, chances and lucks play the most important role on the road to success.San Francisco Asian Escorts
                         
                        #12

                          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