I have a VBS script that builds an Outlook Email signature and saves it to the user's machine. I want this to be called each time the user logs in, using group policy, but so far I've had no luck.
The script is as follows:
Set oShell = CreateObject("WScript.Shell") Set objFSO = CreateObject( "Scripting.FileSystemObject" ) strUserName = oShell.ExpandEnvironmentStrings("%USERNAME%") strTargetPath = oShell.ExpandEnvironmentStrings("%APPDATA%") myURL = "http://example.com/tools/signature/build.php?user=" & strUserName myPath = strTargetPath & "\Microsoft\Signatures\Default.htm" Dim i, objFile, objFSO, objHTTP, strFile, strMsg Const ForReading = 1, ForWriting = 2, ForAppending = 8 If objFSO.FolderExists( myPath ) Then strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) ) ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then strFile = myPath Else End If Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True ) Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" ) objHTTP.Open "GET", myURL, False objHTTP.Send For i = 1 To LenB( objHTTP.ResponseBody ) objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) ) Next objFile.Close( )
The Group Policy was setup against the 'User Configuration' in
Policies -> Windows Settings -> Scripts -> Logon
And this points to the script on the server.
When I run the script locally, it works without any visible errors and the signature is created correctly.
Can anyone see why this wouldn't run correctly, and where (if any) logs or errors would be written to on the server?