Re: VBScript Windows 7 / Windows Vista

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks for the tip,

I will try the Bat file now,

in my VBScript the files where indented for readability, they just
didn't come across very well. (either that or I had word wrapping
turned on when I copied them)
re: The spelling mistake, I checked the source and this spelling
mistake did not exist.

I ended up reducing the script to just the following

'==========================================================================

Dim objFSO
Dim objShell
Dim objSourceFolder
Dim intSourceFileCount
Dim intFileCount

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

objITXLogoDirectory = objShell.ExpandEnvironmentStrings("%WinDir%") &
"\system32\oobe\info\backgrounds"
objITXLogoSource = objShell.ExpandEnvironmentStrings("%LogonServer%")
& "\netlogon\ITX_Backgrounds"
Set objSourceFolder = objFSO.GetFolder(objITXLogoSource)

For Each objFile In objSourceFolder.Files
intSourceFileCount = intSourceFileCount + 1
Next

With objFSO
If .FolderExists(objITXLogoDirectory) = False Then
'Folder doesn't exist, So Create Folder, then Copy Images
'Need to check each level of the directory Structure
If .FolderExists(objShell.ExpandEnvironmentStrings("%Windir%") &
"\system32\oobe") = False Then objFSO.CreateFolder
(objShell.ExpandEnvironmentStrings("%Windir%") & "\system32\oobe\")
If .FolderExists(objShell.ExpandEnvironmentStrings("%Windir%") &
"\system32\oobe\info") = False Then objFSO.CreateFolder
(objShell.ExpandEnvironmentStrings("%Windir%") & "\system32\oobe\info
\")
If .FolderExists(objShell.ExpandEnvironmentStrings("%Windir%") &
"\system32\oobe\info\backgrounds") = False Then objFSO.CreateFolder
(objShell.ExpandEnvironmentStrings("%Windir%") & "\system32\oobe\info
\backgrounds\")
Set objSourceFolder = objFSO.GetFolder(objITXLogoSource)
End If
End With

strCommandtoRun = "xcopy " & objSourceFolder & "\*.* " &
objITXLogoDirectory & "\"
objShell.Run strCommandToRun
'Wscript.echo strCommandToRun

With objShell
.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\Authentication\LogonUI\Background", 1, "REG_DWORD"
End With

'Set the correct Registry Value if it hasn't been set by the Login
Script yet
'HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI
\Background

'==========================================================================


and noticed that neither the folders where created, nor where the
registry entry made.
This was set as a startup script in Windows 2008 on a Windows 7
desktop.
- So if rules of GPO are true, the script should have access to HKLM
to make the registry modifications.
- I confirmed that the Domain Computers have read access to the
netlogon directory
- No Files are created in C:\Windows\System32\oobe\info nor in C:
\Windows\SysWOW64\oobe\ as I thought maybe WOW might be causing the
problem.
- Because it is a startup script, It is difficult for me to put any
debugging code in there (at least I think it is)


I did make some modifications to your BAT file, the contents are
below.

#
==========================================================================

@echo off
set objITXLogoDirectory=%WinDir%\system32\oobe\info\backgrounds\
set objITXLogoSource=%LogonServer%\NetLogon\ITX_Backgrounds\

If not exist %Windir%\system32\oobe\info\backgrounds md %Windir%
\system32\oobe\info\backgrounds
echo xcopy /d /c "%objITXLogoSource%\*.jpg" "%objITXLogoDirectory%" >>
c:\test.txt
xcopy /d /c "%objITXLogoSource%*.jpg" "%objITXLogoDirectory%" 1>>c:
\test.txt 2>>&1

echo > "%Temp%\temp.reg" REGEDIT4
echo >>"%Temp%\temp.reg" [HKey_Local_Machine\Software\Microsoft\Windows
\CurrentVersion\Authenticatio­n\LogonUI]
echo >>"%Temp%\temp.reg" "Background"=dword:1
regedit /s "%Temp%\temp.reg"

del "%temp%\temp.reg" /y

#
==========================================================================
The bat file seemed to work fine, however, as This is just a pre-
cursor to some of the things I plan to do via Login Script, I would
like to know why the VBScript failed.
Time to break it down into managable chunks I think :)

- What's the best way to output a Startup Script (VBScript) to a text
file?
.



Relevant Pages

  • Re: LDAP query information
    ... execution of the vbscript? ... The error message indicates the line number in the script, ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Ping Steve Yandl or other VBScript gurus
    ... way to launch Word invisibly and then have it execute a specific macro. ... included a sample VBScript that demonstrated the idea. ... I'm trying to add one small wrinkle to the script and can't figure out how ... dim bWaitOnReturn ...
    (microsoft.public.word.vba.general)
  • Re: Internet Explorer Automation with VB6, Click Buttons, Enter Passwords
    ... there's no such thing as "VB6 script". ... VBScript is not just uncompiled VB. ... Dim ie as Object is not valid. ...
    (comp.lang.basic.visual.misc)
  • Re: Loginscript (VBScript)
    ... Isolved creating a .bat file. ... I made a vbscript to copy a file to users desktop, ... Where did you specify the script? ... The computer configuration scripts however run in the SYSTEM's context ...
    (microsoft.public.windows.group_policy)
  • Re: Automatic Build Tool contd
    ... > You can easily grab contacts from an Outlook group using some VBScript. ... select Project Global Script and then in the script ... > Dim myNameSpace ... we spent some time evaluating which scripting languages to support. ...
    (borland.public.delphi.thirdpartytools.general)