|
|
I've logged this in the AD group but I think it is probably a scripting issue... If anyone can help I'll be eternally grateful...
I created a VBscript login script under computer config on the default domain policy. It checks the size and date last modified of a file on the local computer (XP pro SP2) and a reference file on the server (Server2003). If they are different it renames the local file and copies the file from the server to replace it.
Even if I log in as domain admins on the local computer and run the script it reports permission denied when trying to run the copy. Despite that user being able to drag and drop between the locations...
System and Domain Computers have full control on the share and security on the server and on the destination on the local machine
Option Explicit
Dim MachineIntegra_Exists, MachineIntegra_Size, MachineIntegraDateLastModified, renamed_file Dim ServerIntegra_Location, MachineIntegra_Location, oFS, oFSUpgradeFolder, oFSMachineIntegra Dim oFSUpgradeLog, , SizeMatch, DateMatch, IntegraChecks, CopyFile Dim ServerIntegra_Exists, ServerIntegra_Size, ServerIntegraDateLastModified, oFSServerIntegra, LoopCount ' Unecessary declarations for renaming function - Dim MachineExecutable, objWMIService
'let's intialise our variables ServerIntegra_Location = "\\poserver\CurrentVersion" MachineIntegra_Location = "c:\program files\integra" Set oFS = CreateObject("Scripting.FileSystemObject") LoopCount = 0
'Set up a log file in C:\temp\upgrade integra 'let's create the location as we go if necessary If Not oFS.FolderExists ("c:\temp\") Then oFSUpgradeFolder = oFS.CreateFolder("c:\temp") End If
If Not oFS.FolderExists("c:\temp\Upgrade Integra") Then oFSUpgradeFolder = oFS.CreateFolder("c:\temp\Upgrade Integra") End If
Set oFSUpgradeLog = oFS.CreateTextFile("C:\temp\Upgrade Integra \Upgrade.log")
'Let's log that we're ready to go oFSUpgradeLog.WriteLine Now() & " Checking for Integra" oFSUpgradeLog.WriteLine Now() & " Location set as " & MachineIntegra_Location
'Now let's find the local and server executable details If oFS.FolderExists(MachineIntegra_Location) Then DoMachineCheck If MachineIntegra_Exists = "True" Then DoServerCheck End If Else 'Oh no something's wrong MachineIntegra_Exists = "False" oFSUpgradeLog.WriteLine Now() & " Machine Integra_Exists = " & MachineIntegra_Exists End If
'Now we need to compare stuff DoComparison
'Now we'll check that the file copy worked... DoMachineCheck DoComparison
Function DoMachineCheck
oFSUpgradeLog.WriteLine Now() & " Folder exists - Checking Integra" Set oFSMachineIntegra = oFS.GetFolder (MachineIntegra_Location) MachineIntegra_Exists = "True" oFSUpgradeLog.WriteLine Now() & " Machine Integra_Exists = " & MachineIntegra_Exists
Set oFSMachineIntegra = oFS.GetFile(MachineIntegra_Location & "\integra.exe") MachineIntegra_Size = oFSMachineIntegra.size MachineIntegraDateLastModified = oFSMachineIntegra.DateLastModified
oFSUpgradeLog.WriteLine Now() & " MachineIntegra_Size = " & oFSMachineIntegra.size oFSUpgradeLog.WriteLine Now() & " MachineIntegraDateLastModified = " & oFSMachineIntegra.DateLastModified
End Function
Function DoServerCheck
If oFS.FolderExists(ServerIntegra_Location) Then oFSUpgradeLog.WriteLine Now() & " Checking Server Integra" Set oFSServerIntegra = oFS.GetFolder (ServerIntegra_Location) ServerIntegra_Exists = "True"
oFSUpgradeLog.WriteLine Now() & " Server Integra_Exists = " & ServerIntegra_Exists
Set oFSServerIntegra = oFS.GetFile(ServerIntegra_Location & "\integra.exe") ServerIntegra_Size = oFSServerIntegra.size ServerIntegraDateLastModified = oFSServerIntegra.DateLastModified
oFSUpgradeLog.WriteLine Now() & " ServerIntegra_Size = " & oFSServerIntegra.size oFSUpgradeLog.WriteLine Now() & " ServerIntegraDateLastModified = " & oFSServerIntegra.DateLastModified Else ServerIntegra_Exists = "False" End If
End Function
Function DoUpdateNonsense
If LoopCount < 3 Then oFSUpgradeLog.WriteLine Now() & " Starting copy attempt number: " & LoopCount 'Let's release our hold on the local file copy the server version over. Set oFSMachineIntegra = Nothing oFSServerIntegra.Copy MachineIntegra_Location, True oFSUpgradeLog.WriteLine Now() & " Copied the current integra executable to " & MachineIntegra_Location Else oFSUpgradeLog.WriteLine Now() & " Loopcount has reached " & LoopCount & "Quitting script" WScript(5) End If
End Function
Function RenameIntegra 'Ideally we will rename the existing file to allow for rollback 'but while this isn't working let's not complicate matters 'Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") 'Set MachineExecutable = GetObject("winMgmts:CIM_DataFile.Name='c: \program files\integra\integra.exe'") 'MachineExecutable.Rename "c:\program files\integra \integra.login_Script_replace.bak" 'Set MachineExecutable = Nothing
End Function
Function DoComparison oFSUpgradeLog.WriteLine Now() & " Checking Size" If ServerIntegra_Size = MachineIntegra_Size Then SizeMatch = True oFSUpgradeLog.WriteLine Now() & " Server Integra Size (" & ServerIntegra_Size & ") matches Machine Integra Size (" & MachineIntegra_Size & ")" Else SizeMatch = False End If
oFSUpgradeLog.WriteLine Now() & " Checking Date" If ServerIntegraDateLastModified = MachineIntegraDateLastModified Then DateMatch = True oFSUpgradeLog.WriteLine Now() & " Server Date Modified (" & ServerIntegraDateLastModified & ") matches Machine Date Modified (" & MachineIntegraDateLastModified & ")" oFSUpgradeLog.WriteLine Now() & " DateMatch = " & DateMatch Else DateMatch = False End If
IntegraChecks = SizeMatch And DateMatch oFSUpgradeLog.WriteLine Now() & " IntegraChecks = " & IntegraChecks
If IntegraChecks = True Then oFSUpgradeLog.WriteLine Now() & " All checks passed. No action necessary" WScript.quit(10) Else LoopCount = LoopCount + 1 oFSUpgradeLog.WriteLine Now() & " Updating Integra" DoUpdateNonsense End If
End Function
|
|
Whew, that's a lot of script to absorb! First, which statement reports the permission denied error?
Next, the file you are attempting to rename, might it be currently locked as a result of the process of logging in, or even of the machine starting up?
Or perhaps this is the problem:
[Quoted Text] > oFSServerIntegra.Copy MachineIntegra_Location, True
At first I thought that this was actually be an attempt to copy the file from the machine to the server, but then I realized I had been thinking of the copyhere method. I've lost track of which object variable refers to what, so I'm not positive, but it could be that while your intention is to copy a file, your script is attempting to copy a folder, which might have different security implications.
At the very least, consider that, since the account has the required privileges to do precisely what you want the script to do, and that the script is throwing an error when it tries to do what it is actually trying to do, that there might be a discrepancy between your intention and the code.
/Al
"Panda" <paul.dambra[ at ]gmail.com> wrote in message news:1178625448.494813.242280[ at ]u30g2000hsc.googlegroups.com... > I've logged this in the AD group but I think it is probably a > scripting issue... If anyone can help I'll be eternally grateful... > > I created a VBscript login script under computer config on the default > domain policy. It checks the size and date last modified of a file on > the local computer (XP pro SP2) and a reference file on the server > (Server2003). If they are different it renames the local file and > copies the file from the server to replace it. > > Even if I log in as domain admins on the local computer and run the > script it reports permission denied when trying to run the copy. > Despite that user being able to drag and drop between the locations... > > System and Domain Computers have full control on the share and > security on the server and on the destination on the local machine > > Option Explicit > > Dim MachineIntegra_Exists, MachineIntegra_Size, > MachineIntegraDateLastModified, renamed_file > Dim ServerIntegra_Location, MachineIntegra_Location, oFS, > oFSUpgradeFolder, oFSMachineIntegra > Dim oFSUpgradeLog, , SizeMatch, DateMatch, IntegraChecks, CopyFile > Dim ServerIntegra_Exists, ServerIntegra_Size, > ServerIntegraDateLastModified, oFSServerIntegra, LoopCount > ' Unecessary declarations for renaming function - Dim > MachineExecutable, objWMIService > > 'let's intialise our variables > ServerIntegra_Location = "\\poserver\CurrentVersion" > MachineIntegra_Location = "c:\program files\integra" > Set oFS = CreateObject("Scripting.FileSystemObject") > LoopCount = 0 > > 'Set up a log file in C:\temp\upgrade integra > 'let's create the location as we go if necessary > If Not oFS.FolderExists ("c:\temp\") Then > oFSUpgradeFolder = oFS.CreateFolder("c:\temp") > End If > > If Not oFS.FolderExists("c:\temp\Upgrade Integra") Then > oFSUpgradeFolder = oFS.CreateFolder("c:\temp\Upgrade Integra") > End If > > Set oFSUpgradeLog = oFS.CreateTextFile("C:\temp\Upgrade Integra > \Upgrade.log") > > 'Let's log that we're ready to go > oFSUpgradeLog.WriteLine Now() & " Checking for Integra" > oFSUpgradeLog.WriteLine Now() & " Location set as " & > MachineIntegra_Location > > 'Now let's find the local and server executable details > If oFS.FolderExists(MachineIntegra_Location) Then > DoMachineCheck > If MachineIntegra_Exists = "True" Then > DoServerCheck > End If > Else > 'Oh no something's wrong > MachineIntegra_Exists = "False" > oFSUpgradeLog.WriteLine Now() & " Machine Integra_Exists = > " & MachineIntegra_Exists > End If > > 'Now we need to compare stuff > DoComparison > > 'Now we'll check that the file copy worked... > DoMachineCheck > DoComparison > > > Function DoMachineCheck > > oFSUpgradeLog.WriteLine Now() & " Folder exists - Checking > Integra" > Set oFSMachineIntegra = oFS.GetFolder > (MachineIntegra_Location) > MachineIntegra_Exists = "True" > oFSUpgradeLog.WriteLine Now() & " Machine > Integra_Exists = " & MachineIntegra_Exists > > Set oFSMachineIntegra = > oFS.GetFile(MachineIntegra_Location & "\integra.exe") > MachineIntegra_Size = oFSMachineIntegra.size > MachineIntegraDateLastModified = > oFSMachineIntegra.DateLastModified > > oFSUpgradeLog.WriteLine Now() & " MachineIntegra_Size > = " & oFSMachineIntegra.size > oFSUpgradeLog.WriteLine Now() & " > MachineIntegraDateLastModified = " & > oFSMachineIntegra.DateLastModified > > End Function > > Function DoServerCheck > > If oFS.FolderExists(ServerIntegra_Location) Then > oFSUpgradeLog.WriteLine Now() & " Checking Server Integra" > Set oFSServerIntegra = oFS.GetFolder > (ServerIntegra_Location) > ServerIntegra_Exists = "True" > > oFSUpgradeLog.WriteLine Now() & " Server > Integra_Exists = " & ServerIntegra_Exists > > Set oFSServerIntegra = > oFS.GetFile(ServerIntegra_Location & "\integra.exe") > ServerIntegra_Size = oFSServerIntegra.size > ServerIntegraDateLastModified = > oFSServerIntegra.DateLastModified > > oFSUpgradeLog.WriteLine Now() & " > ServerIntegra_Size = " & oFSServerIntegra.size > oFSUpgradeLog.WriteLine Now() & " > ServerIntegraDateLastModified = " & oFSServerIntegra.DateLastModified > Else > ServerIntegra_Exists = "False" > End If > > End Function > > Function DoUpdateNonsense > > If LoopCount < 3 Then > oFSUpgradeLog.WriteLine Now() & " Starting copy attempt > number: " & LoopCount > 'Let's release our hold on the local file copy the server > version over. > Set oFSMachineIntegra = Nothing > oFSServerIntegra.Copy MachineIntegra_Location, True > oFSUpgradeLog.WriteLine Now() & " Copied the current > integra executable to " & MachineIntegra_Location > Else > oFSUpgradeLog.WriteLine Now() & " Loopcount has reached " & > LoopCount & "Quitting script" > WScript(5) > End If > > End Function > > Function RenameIntegra > 'Ideally we will rename the existing file to allow for rollback > 'but while this isn't working let's not complicate matters > 'Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") > 'Set MachineExecutable = GetObject("winMgmts:CIM_DataFile.Name='c: > \program files\integra\integra.exe'") > 'MachineExecutable.Rename "c:\program files\integra > \integra.login_Script_replace.bak" > 'Set MachineExecutable = Nothing > > End Function > > Function DoComparison > oFSUpgradeLog.WriteLine Now() & " Checking Size" > If ServerIntegra_Size = MachineIntegra_Size Then > SizeMatch = True > oFSUpgradeLog.WriteLine Now() & " Server Integra Size (" & > ServerIntegra_Size & ") matches Machine Integra Size (" & > MachineIntegra_Size & ")" > Else > SizeMatch = False > End If > > oFSUpgradeLog.WriteLine Now() & " Checking Date" > If ServerIntegraDateLastModified = MachineIntegraDateLastModified > Then > DateMatch = True > oFSUpgradeLog.WriteLine Now() & " Server Date Modified (" & > ServerIntegraDateLastModified & ") matches Machine Date Modified (" & > MachineIntegraDateLastModified & ")" > oFSUpgradeLog.WriteLine Now() & " DateMatch = " & DateMatch > Else > DateMatch = False > End If > > IntegraChecks = SizeMatch And DateMatch > oFSUpgradeLog.WriteLine Now() & " IntegraChecks = " & > IntegraChecks > > If IntegraChecks = True Then > oFSUpgradeLog.WriteLine Now() & " All checks passed. No > action necessary" > WScript.quit(10) > Else > LoopCount = LoopCount + 1 > oFSUpgradeLog.WriteLine Now() & " Updating Integra" > DoUpdateNonsense > End If > > End Function >
|
|
|