Hello all.
I been having an issue with users that logon to terminal services
losing permissions in the registry. To try to narrow it down to a
specific server an trying to write a logoff script that tries to write
a value to the registry and logs the server, user and time that the
error occurs. The issue is that I cannot trap the error using
regWrite.. is there a better way... Or a way I can through a script
verify if a user has rights to their hive on logoff.. Any help would be
awesome.. Here is what I have so far.
Set sho = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set nwo = CreateObject("WScript.Network")
If Not fso.FolderExists("c:\applog") Then
fso.CreateFolder("c:\applog")
End If
'Set outFile =
fso.CreateTextFile("\\GO001W2K037\profiles4\HiveLog\Hivelog.txt",8)
If Not not fso.FileExists ("C:\Applog\Hivelog.txt") Then
Set outFile = fso.CreateTextFile("C:\Applog\Hivelog.txt",8)
Else
Set outFile = fso.openTextFile("C:\Applog\Hivelog.txt",8)
End If
strMachineName=sho.expandenvironmentstrings("%computername%")
strUserName=sho.expandenvironmentstrings("%username%")
Checkit=sho.RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\ICANDOIT",0,"REG_DWORD")
If Checkit <> 0 Then
outFile.Writeline (VbCrLf)
outFile.Writeline ("User: " & strUserName & VbCrLf & "Server: " &
strMachineName & VbCrLf & "Time: " & Now)
End If
outFile.Close
WScript.Quit