RFEMHelpdesk
asked on
Urgent need! - VBS Script to add/modify registry values in logon script
We are implementing a VDI solution, however our document management system is not playing nice with the installation. We have some batch files that once executed "customize" the functionality of the DMS. I want to combine these three batch files into a logon script that can be pushed via GPO so that they are executed at logon for those users utilizing the VDI environment. I will include the batch files below. These were created prior to my arrival when a third party vendor did the DMS implementation. We currently have to run these scripts every time we create a new user. I believe there is some overlap of what is being done. If someone could assist in getting this streamlined and consolidated to where it can be included in a VBS logon script, it would be greatly appreciated.
Thank you in advance!
~Schu
Thank you in advance!
~Schu
64bitauthordefault.bat
echo Windows Registry Editor Version 5.00 > c:\newdocauthdef.reg
echo [HKEY_CURRENT_USER\Software\wow6432node\Interwoven\WorkSite\8.0\iManExt\DefaultNewProfile] >> c:\newdocauthdef.reg
echo "382"="%USERNAME%" >> c:\newdocauthdef.reg
regedit.exe /s "c:\newdocauthdef.reg"
pause
64bitDelete_iManO2k.bat
@echo off
echo Deleteing iMan02K.dot
del "C:\program files\officexp\office10\startup\imano2k.dot"
del "C:\Program Files\Microsoft Office\OFFICE11\STARTUP\imanO2k.dot"
del "C:\Program Files\Microsoft Office\OFFICE12\STARTUP\imanO2k.dot"
del "C:\Program Files\Microsoft Office\OFFICE13\STARTUP\imanO2k.dot"
del "C:\Program Files\Microsoft Office\OFFICE14\STARTUP\imanO2k.dot"
Echo Deleted!
64bitImport_Reg_Keys.bat
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\Autologin.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\Show Worklist on Startup.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\NoEMAILinClassField.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\MaximumSearchRows1000.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\ProfileEmailImport.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\UseDescriptionForMail.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\DefaultNewProfileValues.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\DefaultNewEmailProfileValues.reg"
rem regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\List Column Headings.reg"
rem regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKCU\SetEchoDriveAndSize.reg
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKLM\CheckNetworkConnection.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKLM\NRLfileOpenWithNativeApp.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKLM\ShowHideExplorerNodes.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKLM\DisableEnhancedIntegration.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKLM\LocalOpenLocalSaveAsON.reg"
regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKLM\UseFolderSecurityON.reg"
rem regedit.exe /s "\\RFIMANAGE\Install$\MailsiteRegKeys\HKLM\DisableLocalSaveAs.reg"
rem regedit.exe /s "\\rfek\rfem\apps\1SMC\regkeys64bit\HKLM\RoamingProfile.reg"
REM ***** Delete iManO2K.dot *********
del "C:\program files\officexp\office10\startup\imano2k.dot"
REM ***** Call script to set value for document "Author" field to %USERANME% *********
\\rfek\rfem\apps\1SMC\batch\64bitauthordefault.bat
REM ***** Copy NRT.INI *********
copy \\\rfek\rfem\apps\1SMC\files\nrt.ini %windir%
pause
ASKER
Do you have an FTP site?
ASKER
I have attached a zip file
regkeys64bit.zip
regkeys64bit.zip
ASKER
Please let me know if you require anything else.
Here's the first part:
' Name: 64BitAuthorDefault.vbs
option explicit
dim wshShell
set wshShell = CreateObject ("wscript.shell")
Dim sKey, sValue
sKey = "HKCU\Software\wow6432node\Interwoven\WorkSite\8.0\iManExt\DefaultNewProfile\382"
sValue = wshShell.ExpandEnvironmentStrings ("%USERNAME%")
wshShell.RegWrite sKey, sValue, "REG_SZ"
Set wshShell = Nothing
Next part :-)
Although, to be honest, this is a brute force thing.. with a bit of time, I can have it lookup the installed version of office and then test & delete based on that. But, you did say urgent :-)
Coralon
'Name: 64bitDelete_iManO2k.vbs
Option Explicit
Dim fso
Set fso = CreateObject("scripting.filesystemobject")
on error resume next
fso.DeleteFile "C:\program files\officexp\office10\startup\imano2k.dot"
fso.DeleteFile "C:\Program Files\Microsoft Office\OFFICE11\STARTUP\imanO2k.dot"
fso.DeleteFile "C:\Program Files\Microsoft Office\OFFICE12\STARTUP\imanO2k.dot"
fso.DeleteFile "C:\Program Files\Microsoft Office\OFFICE13\STARTUP\imanO2k.dot"
fso.DeleteFile "C:\Program Files\Microsoft Office\OFFICE14\STARTUP\imanO2k.dot"
Set fso = Nothing
Although, to be honest, this is a brute force thing.. with a bit of time, I can have it lookup the installed version of office and then test & delete based on that. But, you did say urgent :-)
Coralon
The last part (quicker than the reg file stuff)
'Name: CopyNRTIni.vbs
option explicit
dim fso
Set fso = createobject("scripting.filesystemobject")
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
Dim sDestFile, sSourceFile
sDestFile = wshShell.ExpandEnvironmentStrings("%WINDIR%") & "\nrt.ini")
sSourceFile = "\\rfek\rfem\apps\1SMC\files\nrt.ini"
If fso.FileExists (sDestFile) Then
'do nothing
Else
fso.CopyFile sSourceFile, sDestFile
endif
Set fso = Nothing
Set wshShell = Nothing
I'll have to tackle the HKLM part after lunch :-) But here is the next part.. also, be aware that the reg file for NoEMAILinClassField.reg can't be converted to vbscript. The problem is that the reg file has some long binary values in it, and the most you can do with vbscript is 2 words -- it just cannot do the longer values.
'Name: ImportHKCUKeys.vbs
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
Dim sBaseKey
sBaseKey = "HKCU\Software\Wow6432Node\Interwoven\WorkSite\8.0\"
Dim sMailSiteKey
sMailSiteKey = sBaseKey & "MailSite\"
wshShell.RegWrite sMailSiteKey & "AutoLogin", 2, "REG_DWORD"
wshShell.RegWrite sMailSiteKey & "ProfileEmailImport", 0, "REG_DWORD"
Dim sRDBKey
sRDBKey = sBaseKey & "MailSite\Registered Databases\"
wshShell.RegWrite sRDBKey & "iManage", "Y", "REG_SZ"
Dim sDLGOptionsKey
sDLGOptionsKey = sBaseKey & "iIntegrationDlg\DocOpenDlg\Options\"
wshShell.RegWrite sDLGOptionsKey & "Show Worklist on startup", "Y", "REG_SZ"
Dim sDisplayDefaultsKey
sDisplayDefaultsKey = sBaseKey & "Common\General\Display Defaults\"
wshShell.RegWrite sDisplayDefaultsKey & "Maximum Rows", 1000, "REG_DWORD"
wshShell.RegWrite sDisplayDefaultsKey & "MaxRowsNonSearch", 500, "REG_DWORD"
Dim sAdvancedKey
sAdvancedKey = sBaseKey & "Common\Advanced Options\"
wshShell.RegWrite sAdvancedKey & "Use Description for Mail", "Y", "REG_SZ"
Dim sDefEmailKey
sDefEmailKey = sBaseKey & "iManExt\DefaultEmailProfile\"
wshShell.RegWrite sDefEmailKey & "384", "GENERAL", "REG_SZ"
wshShell.RegWrite sDefEmailKey & "3361", "EMAIL", "REG_SZ"
wshShell.RegWrite sDefEmailKey & "3362", "N", "REG_SZ"
wshShell.RegWrite sDefEmailKey & "3380", "N", "REG_SZ"
wshShell.RegWrite sDefEmailKey & "3381", "N", "REG_SZ"
wshShell.RegWrite sDefEmailKey & "3382", "N", "REG_SZ"
wshShell.RegWrite sDefEmailKey & "3383", "N", "REG_SZ"
Dim sDefProfKey
sDefProfKey = sBaseKey & "iManExt\DefaultNewProfile"
[HKEY_CURRENT_USER\Software\wow6432node\Interwoven\WorkSite\8.0\iManExt\DefaultNewProfile]
wshShell.RegWrite sDefProfKey & "384", "GENERAL", "REG_SZ"
wshShell.RegWrite sDefProfKey & "3361", "NONE", "REG_SZ"
wshShell.RegWrite sDefProfKey & "3362", "N", "REG_SZ"
wshShell.RegWrite sDefProfKey & "3380", "N", "REG_SZ"
wshShell.RegWrite sDefProfKey & "3381", "N", "REG_SZ"
wshShell.RegWrite sDefProfKey & "3382", "N", "REG_SZ"
wshShell.RegWrite sDefProfKey & "3383", "N", "REG_SZ"
Set wshShell = Nothing
Sorry.. I meant the NRLfileOpenWithNativeApp.r eg file. That's the one with binary values.
Coralon
Coralon
ASKER
Urgent meaning by Monday. Can we do the lookup by then?
And another note :-) The HKCU stuff all has the Wow6432Node reference in it, and I believe that is *probably* wrong. In the HKCU side, everything normally registers directly under HKCU\Software.. it never has that Wow6432Node reference, except for a very very small handful of Microsoft keys/values.
If I am correct, you can just remove that reference from the sBaseKey to update the rest of the script
Coralon
If I am correct, you can just remove that reference from the sBaseKey to update the rest of the script
sBaseKey = "HKCU\Software\Interwoven\WorkSite\8.0\"
Coralon
Here's the HKLM machine part - this really only has to be done once for the machine, whereas the user script woudl have to be done for each user:
'Name: ImportHKLMValues.vbs
Option Explicit
Dim wshShell
Set wshShell = CreateObject ("WScript.Shell")
Dim sWorkSiteKey
sWorkSiteKey = "HKLM\Software\Wow6432Node\Interwoven\Worksite\8.0\"
Dim sOptionsKey
sOptionsKey = sBaseKey & "Common\Options\"
wshShell.RegWrite sOptionsKey & "CheckNetworkConnection", 1, "REG_DWORD"
wshShell.RegWrite sOptionsKey & "Show Explorer Nodes Mask", 1, "REG_DWORD"
wshShell.RegWrite sOptionsKey & "UseFolderSecurity", "N", "REG_SZ"
dim sMenuKey
sMenuKey = sWorkSiteKey & "\Integration\MenuSettings\"
wshShell.RegWrite sMenuKey & "SETFOOTER", "Y", "REG_SZ"
wshShell.RegWrite sMenuKey & "LOCALOPEN", "Y", "REG_SZ"
wshShell.RegWrite sMenuKey & "LOCALSAVEAS", "Y", "REG_SZ"
wshShell.RegWrite "HKLM\CurrentControlSet\Services\Tcpip\Parameters\DisableDHCPMediaSense", 1, "REG_DWORD"
Set wshShell = Nothing
Here's the updated code to check and delete the files that we were talking about before. In theory, it can be more complicated and detect the actual installs of Office, but that is way more complicated than it's worth.
The only hitch to this is if you are installing the 32bit versions of Office on a 64 bit machine. In that case, you would need to switch c:\program files with c:\program files (x86)
And as for that one reg file with the binary values, you will need to keep that as a .reg file.. but since it is HKLM, it only needs to be done once per machine :-)
Coralon
Coralon
'Name: 64bitDelete_iManO2k.vbs
Option Explicit
Dim fso
Set fso = CreateObject("scripting.filesystemobject")
Dim sFile, sFileArray
sFileArray = Array("C:\program files\officexp\office10\startup\imano2k.dot", "C:\Program Files\Microsoft Office\OFFICE11\STARTUP\imanO2k.dot", "C:\Program Files\Microsoft Office\OFFICE12\STARTUP\imanO2k.dot", "C:\Program Files\Microsoft Office\OFFICE13\STARTUP\imanO2k.dot", "C:\Program Files\Microsoft Office\OFFICE14\STARTUP\imanO2k.dot")
For Each sFile In sFileArray
If fso.FileExists(sFile) then
fso.DeleteFile sFile, vbTRUE
end If
Next
Set fso = Nothing
The only hitch to this is if you are installing the 32bit versions of Office on a 64 bit machine. In that case, you would need to switch c:\program files with c:\program files (x86)
And as for that one reg file with the binary values, you will need to keep that as a .reg file.. but since it is HKLM, it only needs to be done once per machine :-)
Coralon
Coralon
ASKER
Thank you SOOOO much for all of the work on this. I am commuting home at this time. I will look into testing it this evening and post any findings at that time.
Great :-) Glad to help.. I hate seeing people doing everything by reg files.. it's annoying and long term a royal pain to support :-)
And, as a side-note -- if you have a Win2k8/Win2k8R2 infrastructure, you can use Group Policy Preferences to deploy these settings instead of the scripts (assuming your clients have the Group Policy Client Extensions (built into Vista/Win7/Win2k8/Win2k8R2 ) (installable on Win2k3/WinXP).
Coralon
And, as a side-note -- if you have a Win2k8/Win2k8R2 infrastructure, you can use Group Policy Preferences to deploy these settings instead of the scripts (assuming your clients have the Group Policy Client Extensions (built into Vista/Win7/Win2k8/Win2k8R2
Coralon
ASKER
How to do that? I do have a Win2k8R2! That is what this whole thing is for! We are deploying VMView Win7 64 Desktops but they are destroyed at logout and a new one is created at next login. Any suggestions?
Definitely! Your life just got a LOT easier :-)
You will create a GPO for the machine OU.
Edit the GPO and in the Machine Section, under Preferences, there is a node for Registry.
Select that and right click, selecting New Registry Item.
From there, it's just a property sheet - you can read the values out of the scripts (or the reg files) and add them to the property sheet. It's a pretty sophisticated mechanic, but simple to use :-)
By using this, everytime a machine boots up in that OU, the registry settings are applied.
For the users, you will do the same thing -- if they will never log in anywhere else, then you can just apply it to their home OU. If not, you can turn on Loopback Processing on the Machine's OU (see below for more info on it).
Any registry item set in the preferences section can be targeted - you can use a graphical wizard to select what specific circumstances you want the item applied in. I can't begin to explain how nice and powerful it is without going on for pages & pages :-D
----
Loopback - this is used to apply USER level policies based on the Machine's OU. There are 2 methods:
Replace - ignores the user's OU for GPOs, only uses the Machine's OU for GPO's.
Merge - uses the machine's OU GPO's for the machine, uses the USER's OU for GPO's for the user, and then uses the machine's OU for USER settings from the GPO's.
I typically use Replace - that way I control *exactly* what the users get for policies.
Coralon
You will create a GPO for the machine OU.
Edit the GPO and in the Machine Section, under Preferences, there is a node for Registry.
Select that and right click, selecting New Registry Item.
From there, it's just a property sheet - you can read the values out of the scripts (or the reg files) and add them to the property sheet. It's a pretty sophisticated mechanic, but simple to use :-)
By using this, everytime a machine boots up in that OU, the registry settings are applied.
For the users, you will do the same thing -- if they will never log in anywhere else, then you can just apply it to their home OU. If not, you can turn on Loopback Processing on the Machine's OU (see below for more info on it).
Any registry item set in the preferences section can be targeted - you can use a graphical wizard to select what specific circumstances you want the item applied in. I can't begin to explain how nice and powerful it is without going on for pages & pages :-D
----
Loopback - this is used to apply USER level policies based on the Machine's OU. There are 2 methods:
Replace - ignores the user's OU for GPOs, only uses the Machine's OU for GPO's.
Merge - uses the machine's OU GPO's for the machine, uses the USER's OU for GPO's for the user, and then uses the machine's OU for USER settings from the GPO's.
I typically use Replace - that way I control *exactly* what the users get for policies.
Coralon
ASKER
OK so i was up until almost three in the morning entering in all of these registry keys in my GPO. I had thought some great miracle was going to occur but, alas, I ended up with the same issues. It did not appear as though any of the changes were applied. I am going to have to dig into it a little bit more. I believe that I may have to delete this users roaming profile and start over so that I have a clean slate to work on. I think that some things are being retained and others are not. With over 70 regmodifications though it is going to be hard to tell without going line by line in the registry with a clean user.
Additionally, there is a piece I found last evening that is going to have to be in the login script, a file copy as it is kept in a volatile area that is deleted at each logout.
Here is what I need (i think) -
copy \\rfek\rfem\apps\1SMC\FRMC ACHE.DAT c:\profiles\users\%usernam e%\AppData \Local
Microsoft\FORMS\FRMCACHE.d at
Can you convert to VB Scipt speak?
Thanks for your help Coralon!
Additionally, there is a piece I found last evening that is going to have to be in the login script, a file copy as it is kept in a volatile area that is deleted at each logout.
Here is what I need (i think) -
copy \\rfek\rfem\apps\1SMC\FRMC
Microsoft\FORMS\FRMCACHE.d
Can you convert to VB Scipt speak?
Thanks for your help Coralon!
Well, as I mentioned in the script, one of my concerns is that they have the HKCU data writing to HKCU\Software\WoW6432node, which is virutally never used..
I would try removing that WoW6432 node from the GPO and see if that works (I'd bet it will), but the clean profile is always a good idea. And the Form Cache definitely would make a difference :-)
And, you can actually add a file copy to the GPO preferences also, as I described it above. It's *very* convenient :-)
Coralon
I would try removing that WoW6432 node from the GPO and see if that works (I'd bet it will), but the clean profile is always a good idea. And the Form Cache definitely would make a difference :-)
option Explicit
dim fso
set fso = CreateObject ("scripting.filesystemobject")
Dim wshShell
Set wshShell = CreateObject ("WScript.Shell")
Dim sSource, sDest, sUserLocalAppData
sSource = "\\rfek\rfem\apps\1SMC\FRMCACHE.DAT"
sUserLocalAppData = wshShell.ExpandEnvironmentStrings("%LOCALAPPDATA%")
sDest = sUserLocalAppData & "\Microsoft\Forms"
fso.CopyFile sSource, sDest, vbTrue
Set fso = Nothing
And, you can actually add a file copy to the GPO preferences also, as I described it above. It's *very* convenient :-)
Coralon
ASKER
Unfortunately, this application does utilize the WoW6432 node. I thought it odd as well but, it is what it is. Thank you for the work on this, I have actually put most of it together in the GPO registry per your suggestion with a few items that need to be approached differently, being handled by snippets of your code. The last piece that I am trying to sort out has to do with a SCC key that is generated for the Microsoft viewer. This key is not generated until such time as you go into the MS Outlook application and make a call. I was told that I need to prepopulate this key I am just not sure what needs populating?
Excerpt from Autonomy:
If the users profile is deleted upon log off, the icons must be downloaded again for the user because the frmcache.dat file is lost. The only way to work around this would be to create a login script that pushes the frmcache.dat file out. This file is used for Outlook views, and if it doesn't exist, we have to re-download the icons.
The OutsideIn message is coming up because the registry keys used for that technology were wiped out. The reg keys are:
HKEY_LOCAL_MACHINE\Softwar e\SCC
HKEY_CURRENT_USER\Software \SCC
These keys need to be maintained or a login script will be needed to re-populate them.
The Outside In registration process can be initiated after a time change on the machine, i.e. Daylight Savings Time. If the DLL files used for the Viewer technology incorporated into the FileSite client have a different time stamp than the system, they may appear to be different and cause the Outside In registration process to initiate. It will not impact any usage of FileSite. This should only happen one time, if at all, on a user's machine as long as they have Write access to the following registry key:
HKEY_LOCAL_MACHINE\SOFTWAR E\SCC
If the permissions have been set to Read Only, this can cause the dll's to re-register every time FileSite is accessed.
Excerpt from Autonomy:
If the users profile is deleted upon log off, the icons must be downloaded again for the user because the frmcache.dat file is lost. The only way to work around this would be to create a login script that pushes the frmcache.dat file out. This file is used for Outlook views, and if it doesn't exist, we have to re-download the icons.
The OutsideIn message is coming up because the registry keys used for that technology were wiped out. The reg keys are:
HKEY_LOCAL_MACHINE\Softwar
HKEY_CURRENT_USER\Software
These keys need to be maintained or a login script will be needed to re-populate them.
The Outside In registration process can be initiated after a time change on the machine, i.e. Daylight Savings Time. If the DLL files used for the Viewer technology incorporated into the FileSite client have a different time stamp than the system, they may appear to be different and cause the Outside In registration process to initiate. It will not impact any usage of FileSite. This should only happen one time, if at all, on a user's machine as long as they have Write access to the following registry key:
HKEY_LOCAL_MACHINE\SOFTWAR
If the permissions have been set to Read Only, this can cause the dll's to re-register every time FileSite is accessed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Coralon, maybe we could take this offline and address it via email. I have many questions concerning this. If you are interested let me know.
~Schu
~Schu
I'll start on it right now though :-)
Coralon