#16950 - 2002-02-02 12:51 AM
Refresh Desktop
|
Leon Mol
Fresh Scripter
Registered: 2002-01-18
Posts: 11
Loc: Netherlands
|
I have written a script to control some setting for my Terminal Server users ( redirecting and renaming 'My documents' etc ). At the end of my script I want to refresh the desktop, but how can I do that ?  I have already tried :
Setconsole("Hide") Sendkeys("{F5}")
But this doesn't work right.Thanks in advance, Leon
|
|
Top
|
|
|
|
#16952 - 2002-02-01 03:23 PM
Re: Refresh Desktop
|
Leon Mol
Fresh Scripter
Registered: 2002-01-18
Posts: 11
Loc: Netherlands
|
Thank you,I change my desktop setting by the registery, like : ; This is just a small part of the kix script $X=WRITEVALUE ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\SHELL FOLDERS" ,"PERSONAL",$DOCAFDDIR,"REG_SZ") $X=WRITEVALUE ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\USER SHELL FOLDERS","PERSONAL",$DOCAFDDIR,"REG_SZ") $X=ADDKEY ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}") $X=WRITEVALUE ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}","",$DOCICNAME,"REG_SZ") $X=WRITEVALUE ("HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}","INFOTIP",$DOCICTTIP,"REG_SZ") $X=WRITEVALUE ("HKEY_LOCAL_MACHINE\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}","INFOTIP",$DOCICTTIP,"REG_SZ"); Settings for 'My computer' $X=WRITEVALUE ("HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","INFOTIP","VERKEN UW MAPPEN EN BESTANDEN","REG_SZ") $X=WRITEVALUE ("HKEY_LOCAL_MACHINE\SOFTWARE\CLASSES\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","INFOTIP","VERKEN UW MAPPEN EN BESTANDEN","REG_SZ") $X=ADDKEY ("HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}") $X=WRITEVALUE ("HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","",$SSERVER +" "+@USERID+" ","REG_SZ") $X=WRITEVALUE ("HKEY_CURRENT_USER\CONTROL PANEL\DESKTOP" ,"PAINTDESKTOPVERSION",1,"REG_DWORD")
I have configured in my AD on the profile tab, that this script must start when the user logs on to the computer or terminal server. In the kix script I get first a part for both, then only for Terminal Server, then only for computers. Changes like renaming 'my computer' in the name of the current terminal server, need a refresh of the desktop. Leon Mol
|
|
Top
|
|
|
|
#16956 - 2002-02-02 12:08 AM
Re: Refresh Desktop
|
Leon Mol
Fresh Scripter
Registered: 2002-01-18
Posts: 11
Loc: Netherlands
|
..What a problem !.. A ugly solution is something like this :;Test.kix CLS SHELL "REF.BAT" SLEEP 1 SENDKEYS("{F5}")
REF.SCF is a copy from the icon that Windows 2000 has placed on the quick launch bar "Show Desktop". This solution need three files. Their must be a better solution ? What is a SCF file ?
|
|
Top
|
|
|
|
#16957 - 2002-02-02 12:09 AM
Re: Refresh Desktop
|
rick_coughlin
Fresh Scripter
Registered: 2000-11-15
Posts: 7
Loc: Gaithersburg, MD, USA
|
I actually just wrote this a few days ago. This may help you out as well.My situation is that I have terminals in all of our scientific labs. At present we have some labs connecting to a MS Terminal server and others connecting to a Citrix MetaFrame server. Some lab personel may have either a PC at thier desk or a Mac (and use the Citrix client). In the past, order to cut down on log in/out times, I have prevented the Desktop directory from being a part of the profile. (Nothing worse then someone droping a 500MB PowerPoint file on the desktop and they wonder why it takes so long to log in/out.) code:
; ----------------------------------------------------------------------- ; ; Prevent Certain Folders from Uploading to Central Profile. ; ; ----------------------------------------------------------------------- ; ? ? "Prevent certain folders from uploading to the central profile:" ? " " IF WRITEVALUE ("Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "ExcludeProfileDirs", "Temporary Internet Files;Desktop;History;Local Settings\Temporary Internet Files;Local Settings\Temp;Local Settings\History;Personal;Start Menu", "REG_SZ") = 0 "Value written to the registry - ExcludeProfileDirs" ELSE "Error writing value to the registry - ExcludeProfileDirs" ENDIF? ? " " ; Policy for Windows 2000 ; IF WRITEVALUE ("Software\Policies\Microsoft\Windows\System\ExcludeProfileDirs", "ExcludeProfileDirs", "Temporary Internet Files;Desktop;History;Local Settings\Temporary Internet Files;Local Settings\Temp;Local Settings\History;Personal;Start Menu", "REG_SZ") = 0 "Value written to the registry - ExcludeProfileDirs" ELSE "Error writing value to the registry - ExcludeProfileDirs" ENDIF ? ? " " IF WRITEVALUE ("Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\LocalUser\Software\Policies\Microsoft\Windows\System", "ExcludeProfileDirs", "Temporary Internet Files;Desktop;History;Local Settings\Temporary Internet Files;Local Settings\Temp;Local Settings\History;Personal;Start Menu", "REG_SZ") = 0 "Value written to the registry - ExcludeProfileDirs" ELSE "Error writing value to the registry - ExcludeProfileDirs" ENDIF
Hrmm.. after looking at that code, I need to really it clean up. Anyways.... My delema now is that we plan on migrating all the users to the MetaFrame server and then rebuild the MS Terminal server with Citrix and creat a cluster. When clients logged into the the cluster, they could get either of the servers. And have a unique desktop on each server. Having unique desktops on each workstation was accecptable. Unique desktops to each TS was not. My solution was to create a "TSDesktop" directory on the Home drive of each user that logged into a TS. Change the attributes of that dirctory to Hidden and System. And to move any files that may be located in the Desktop dirctory on the Terminal servers to the new TSDesktop directory. I also wanted the Desktop directory to revert back to the local profile if the user logged onto a workstation. I'm currently still testing the impact of this code on several users but have yet to have any problems with it. Quick note: I define the $UserDrive variable at the begining of the script when I use it to map the users Home Directory. code:
DIM $TSDesktop = "TSDesktop" ; Directory for the Terminal Server Desktop DIM $UserDrive = "H" ; Mapped drive for the User Directory ? "Creating the " + $TSDesktop + " directory:" ? " " IF @PRODUCTSUITE = 18 IF DIR ($UserDrive + ":\" + $TSDesktop) = $TSDesktop "Directory already exists - " + $UserDrive + ":\" + $TSDesktop ELSE MD $UserDrive + ":\" + $TSDesktop IF @ERROR = 0 "Directory has been created successfully - " + $UserDrive + ":\" + $TSDesktop ? " " SETFILEATTR ($UserDrive + ":\" + $TSDesktop, 6) COPY "%USERPROFILE%\Desktop\*.*" $UserDrive + ":\" + $TSDesktop DEL "%USERPROFILE%\Desktop\*.*" ELSE "Error creating directory - " + $UserDrive + ":\" + $TSDesktop ENDIF ENDIF WRITEVALUE ("Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", $UserDrive + ":\" + $TSDesktop, "REG_EXPAND_SZ") ELSE WRITEVALUE ("Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", "%USERPROFILE%\Desktop", "REG_EXPAND_SZ") ENDIF
|
|
Top
|
|
|
|
#16958 - 2002-02-02 12:41 AM
Re: Refresh Desktop
|
Leon Mol
Fresh Scripter
Registered: 2002-01-18
Posts: 11
Loc: Netherlands
|
Reply to message from: rick_coughlin Thank you,Yes, that's also a possibility, making a desktop for each terminal server, or a centralized desktop for all terminal servers. My only problem is then the 'My documents' that has a user/department specific path and icon name ( for redirecting files for user, works from any application. ). In the new desktop path, you will be able to great folders like :
Inbox.{00020D76-0000-0000-C000-000000000046} My Computer.{20D04FE0-3AEA-1069-A2D8-08002B30309D} Printers.{2227A280-3AEA-1069-A2DE-08002B30309D} Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E} The Internet.{FBF23B42-E3F0-101B-8488-00AA003E56F8}
That would be nice...
|
|
Top
|
|
|
|
#16959 - 2002-02-02 03:20 AM
Re: Refresh Desktop
|
rick_coughlin
Fresh Scripter
Registered: 2000-11-15
Posts: 7
Loc: Gaithersburg, MD, USA
|
I have also changed the value of the "My Documents" folder.If a user clicks on the "My Documents" icon on the desktop, they are directed to the directory I create for them in thier Home drive. The Home drive is mapped to a hidden share for each user. The H: drive is mapped to "\@USERID"+"$" elsewhere in the script. With Office 97, this was very easy to do in KiXtart. In fact, it's how I did it before migrating to Office 2000. Here is the KiXtart code I used for Office 97. code:
; Set Office 97 "policies" via this script.$UserDrive = "H" ; Mapped drive for the User Directory $ProjectDrive = "P" ; Mapped drive for the Shared Project Directory $OfficeFiles = "Personal Documents" ; Directory for Users Personal Office Documents $OfficeTemplates = "Templates" ; Directory for Users Personal Office Templates $OutlookFiles = "Outlook" ; Directory for Users Outlook Files $SharedOfficeFiles = "Shared Documents" ; Directory for Users Shared Office Documents $SharedOfficeTemplates = "Templates" ; Directory for Users Shared Office Templates ; Set the user's home directory to their share on the Home Server. IF %OS% = "Windows_NT" SET "HOMEDRIVE=" + $UserDrive + ":" ? " HOMEDRIVE set to " + $UserDrive + ":" ENDIF
; Create the "Personal Documents" folder if it does not exist. ? ? "Creating the " + $OfficeFiles + " directory:" ? " " IF DIR ($UserDrive + ":\" + $OfficeFiles) = $OfficeFiles "Directory already exists - " + $UserDrive + ":\" + $OfficeFiles ELSE MD $UserDrive + ":\" + $OfficeFiles IF @ERROR = 0 "Directory has been created successfully - " + $UserDrive + ":\" + $OfficeFiles ELSE "Error creating directory - " + $UserDrive + ":\" + $OfficeFiles ENDIF ENDIF
; Create the "Templates" folder if it does not exist. ? ? "Creating the " + $OfficeTemplates + " directory:" ? " " IF DIR ($UserDrive + ":\" + $OfficeFiles + "\" + $OfficeTemplates) = $OfficeTemplates "Directory already exists - " + $UserDrive + ":\" + $OfficeFiles + "\" + $OfficeTemplates ELSE MD $UserDrive + ":\" + $OfficeFiles + "\" + $OfficeTemplates IF @ERROR = 0 "Directory has been created successfully - " + $UserDrive + ":\" + $OfficeFiles + "\" + $OfficeTemplates ELSE "Error creating directory - " + $UserDrive + ":\" + $OfficeFiles + "\" + $OfficeTemplates ENDIF ENDIF ; Create the "Outlook" folder if it does not exist. ? ? "Creating the " + $OutlookFiles + " directory:" ? " " IF DIR ($UserDrive + ":\" + $OfficeFiles + "\" + $OutlookFiles) = $OutlookFiles "Directory already exists - " + $UserDrive + ":\" + $OfficeFiles + "\" + $OutlookFiles ELSE MD $UserDrive + ":\" + $OfficeFiles + "\" + $OutlookFiles IF @ERROR = 0 "Directory has been created successfully - " + $UserDrive + ":\" + $OfficeFiles + "\" + $OutlookFiles ELSE "Error creating directory - " + $UserDrive + ":\" + $OfficeFiles + "\" + $OutlookFiles ENDIF ENDIF ; Path to the Personal Folder used by all Office Apps. ? ? "Set the path of the Personal folder used by all Office 97 apps." ? " " IF WRITEVALUE ("Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal", $UserDrive + ":\" + $OfficeFiles, "REG_EXPAND_SZ") = 0 "Value written to the registry - Personal" ELSE "Error writing value to the registry - Personal" ENDIF IF DELVALUE ("Software\Microsoft\Office\8.0\Excel\Microsoft Excel", "DefaultPath") = 0 ? " Value deleted from the registry - DefaultPath" ENDIF IF DELVALUE ("Software\Microsoft\Office\8.0\Access\Settings", "Default Database Directory") = 0 ? " Value deleted from the registry - Default Database Directory" ENDIF IF DELVALUE ("Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default", "") = 0 ? " Value deleted from the registry - Recent Folder List\Default" ENDIF IF DELVALUE ("Software\Microsoft\Office\8.0\Binder", "DefaultDirectory") = 0 ? " Value deleted from the registry - DefaultDirectory" ENDIF IF DELVALUE ("Software\Microsoft\Office\8.0\Word\Options", "DOC-PATH") = 0 ? " Value deleted from the registry - DOC-PATH" ENDIF ; Path to the User Templates Folder used by all Office 97 Apps. ; ? ? "Set the path of the User Templates folder used by all Office 97 apps." IF WRITEVALUE ("Software\Microsoft\Office\8.0\Common\FileNew\LocalTemplates", "", $UserDrive + ":\" + $OfficeFiles + "\" + $OfficeTemplates, "REG_SZ") = 0 ? " Value written to the registry - LocalTemplates" ENDIF ; Path to the Workgroup Templates Folder used by all Office 97 Apps. ; ? ? "Set the path of the Workgroup Templates folder used by all Office 97 apps." IF ADDKEY("HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Common\FileNew\SharedTemplates") = 0 ? " Key added to the registry - SharedTemplates" ENDIF IF ADDKEY("HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\TemplateDir") = 0 ? " Key added to the registry - TemplateDir" ENDIF IF WRITEVALUE ("Software\Microsoft\Office\8.0\Common\FileNew\SharedTemplates", "", $ProjectDrive + ":\" + $SharedOfficeFiles + "\" + $SharedOfficeTemplates, "REG_SZ") = 0 ? " Value written to the registry - SharedTemplates" ENDIF IF WRITEVALUE ("Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\TemplateDir", "", $ProjectDrive + ":\" + $SharedOfficeFiles + "\" + $SharedOfficeTemplates, "REG_SZ") = 0 ? " Value written to the registry - TemplateDir" ENDIF
Now, if your using Office 2000, there is a problem. MS moved the location of these registry keys into the Policies of the HKCU and gave Everyone read only permissions. Administrators and System have full control. I wrote a script for all of the new keys, but it won't do your useres any good if they don't have the correct permissions to modify the keys. My solution was to use a good old fashioned Policy. I took the new .POL files for Office 2000 and modified them so that they are backwards compatible with the NT 4.0 policy editor. Due to management policies beyond my control, we are not able to go to an active directory structure and are forced to remain in an NT 4.0 domain model. Otherwise, I would just be using the Group Policies in the Active Directory. If you would like a copy of those .POL files, let me know and I can email them to you.
|
|
Top
|
|
|
|
#16960 - 2002-02-03 12:04 AM
Re: Refresh Desktop
|
Leon Mol
Fresh Scripter
Registered: 2002-01-18
Posts: 11
Loc: Netherlands
|
Redirecting the ‘My documents’ is not my problem. I create a INI-file with a key for each UserId. Under a key some parameters with one for the locations where the user has his home location: ; A little part of the INI-file we use[L.Mol] DIV = IT DOC-ICNAME = Map IT DOC-ICTTIP = DOC-AFDSHR = Group DOC-AFDDIR = G:\head office\economic administrative department\information technology PER-LET001 = U: PER-MAP001 = \\App1\lmol$ SHR-LET001 = K: SHR-MAP001 = \\App1\clienten SHR-LET002 = I: SHR-MAP002 = \\App1\install$
( created a small program to convert this INI file to CSV and backwards ) The values are read by the KiXscript . $UGET is the location of a central INI file. This could be a location at a windows 2000 Sysvol. ; Reading the INI-file $DOCICNAME = READPROFILESTRING ($UGET , @WUSERID, "DOC-ICNAME") $DOCICTTIP = READPROFILESTRING ($UGET , @WUSERID, "DOC-ICTTIP") $DOCAFDSHR = READPROFILESTRING ($UGET , @WUSERID, "DOC-AFDSHR") $DOCAFDDIR = READPROFILESTRING ($UGET , @WUSERID, "DOC-AFDDIR")
With this kix part, that was mentioned before I changed my registry settings to change the 'my documents' icon and folder settings: ; Changes for 'my documents' ; Folder change $X=WRITEVALUE ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\SHELL FOLDERS" ,"PERSONAL",$DOCAFDDIR,"REG_SZ") $X=WRITEVALUE ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\USER SHELL FOLDERS","PERSONAL",$DOCAFDDIR,"REG_SZ") ; Change ‘my documents’ in a new name for the icon $X=ADDKEY ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}") $X=WRITEVALUE ("SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}","",$DOCICNAME,"REG_SZ") $X=WRITEVALUE ("HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}","INFOTIP",$DOCICTTIP,"REG_SZ") $X=WRITEVALUE ("HKEY_LOCAL_MACHINE\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}","INFOTIP",$DOCICTTIP,"REG_SZ")
This works perfect. A program like Word/Excel and many other program reads the location for the string that was set in the script above, and use this path to save documents to. But with changing the name of a special folder like this, the user needs to refresh his desktop. With a centralized desktop, I don’t know if a script like above will work.
|
|
Top
|
|
|
|
#16961 - 2002-02-04 10:26 AM
Re: Refresh Desktop
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
leon, i just checked for your foundary... Show Desktop is just a ini file with scf-extension.in it's simplicity, the needed lines are: [Shell] Command=2 [Taskbar] Command=ToggleDesktop and it works nicely... so easy way to refresh desktop is use kix's ini-file-functions and create these two entries in to any_name.scf then run it. is that easy enough? cheers,
_________________________
!download KiXnet
|
|
Top
|
|
|
|
#16962 - 2002-03-04 06:28 PM
Re: Refresh Desktop
|
MyITGuy
Fresh Scripter
Registered: 2001-01-30
Posts: 11
|
I refresh the desktop like this:SetFocus("Program Manager") SendKeys("{F5}") Works fine on 2000/XP, have not tried NT4/9x boxes. Could someone let me know if it does? Thx [ 04 March 2002: Message edited by: MyITGuy ]
_________________________
Automating your life to make my life easier.
|
|
Top
|
|
|
|
#16963 - 2002-03-14 09:51 AM
Re: Refresh Desktop
|
Leon Mol
Fresh Scripter
Registered: 2002-01-18
Posts: 11
Loc: Netherlands
|
The functions :
SetFocus("Program Manager") SendKeys("{F5}")
seems to work on Windows 2000 Terminal Server.
Thanks for your help ...
Leon Mol
|
|
Top
|
|
|
|
#16964 - 2002-05-30 11:01 PM
Re: Refresh Desktop
|
Anonymous
Anonymous
Unregistered
|
SetFocus("Program Manager") SendKeys("{F5}")
Works great!
Is there a way to do this to the "Quick Launch" bar?
I am deleting items, and rebuilding items in the logon scripts. When Windows 2000 finally comes up, the Quick Launch bar is empty, and I can right-click and select "Refresh" and the items are there.
I want to do this when the KIX script finishes.
|
|
Top
|
|
|
|
#16966 - 2002-05-30 11:36 PM
Re: Refresh Desktop
|
Anonymous
Anonymous
Unregistered
|
Thank You!!!!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1607 anonymous users online.
|
|
|