Ok, so basically I am wanting to copy a registry entry then save it to the users profile. Once the user connects to a different server I want that registry entry to run and import in that registry. I am having a problem importing the registry key. I have the script check to see if the file exists on the other server. If it doesn't then the script doesn't run. If it does exist then run the registry key. For some reason that file exist command does not work. Can anyone shed some light?
'Script to copy Printer settings from 2003 profiles and import setting to 2008 profile.
Set WshShell = CreateObject("WScript.Shell")
Dim objFSO
Set objFso = CreateObject("Scripting.FileSystemObject")
set objWshShell = WScript.CreateObject("WScript.Shell")
strOS = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
If strOS = "Microsoft Windows Server 2003" Then
If Not objFso.FileExists("\\SERVER\profile$\%username%\printers.reg") Then
objWshShell.Run "regedit /e \\SERVER1\profile$\%username%\printers.reg HKEY_CURRENT_USER\Printers",0,TRUE
Else
Wscript.Quit
End If
End If
If strOS = "Windows Server (R) 2008 Enterprise" Then
If Not objFso.FileExists("\\SERVER\profile$\%username%\printers.reg") Then
Wscript.Quit
Else
objWshShell.Run "regedit /s \\SERVER\profile$\%username%\printers.reg",0,TRUE
End If
End If
'Script to copy Printer settings from 2003 profiles and import setting to 2008 profile.
Set WshShell = CreateObject("WScript.Shell")
Dim objFSO
Set objFso = CreateObject("Scripting.FileSystemObject")
set objWshShell = WScript.CreateObject("WScript.Shell")
strOS = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
If strOS = "Microsoft Windows Server 2003" Then
If Not objFso.FileExists("\\SERVER\profile$\%username%\printers.reg") Then
objWshShell.Run "regedit /e \\SERVER1\profile$\%username%\printers.reg HKEY_CURRENT_USER\Printers",0,TRUE
Else
Wscript.Quit
End If
End If
If strOS = "Windows Server (R) 2008 Enterprise" Then
If Not objFso.FileExists("\\SERVER\profile$\%username%\printers.reg") Then
Wscript.Quit
Else
objWshShell.Run "regedit /s \\SERVER\profile$\%username%\printers.reg",0,TRUE
End If
End If