Change theme in Windows XP or Windows 7 (silently) - windows

could you please help me?
What I need is a method to change the theme on a Windows machine without prompting the user with the display properties (personalization) window. The themechange should apply a .theme file from the c:\windows\resources\themes\ directory and NOT apply a new .msstyles. Method should only apply a .theme file. I have just been unable to find a way to apply the theme without causing the personalization window to appear. To emphasize, I dont want to solve this via scripts or macros. And also, closing the window via "sendkeys" is not an option, because it will still be seen momentarily.
Maybe there is a way out through WINAPI function or simple registry hack? Please, give me advice. Thank you.
Best regards

'Script name: yourtheme.vbs
'Object: Automate without command prompt the application of a Windows Theme by a VB script
'
'SCRIPT CONTENTS:
'Define Variables :
Set ShellApp = CreateObject("Shell.Application")
Set WsShell = CreateObject("Wscript.Shell")
'
'Define path for your file theme (put it on a network share and don't forget to apply "read and execute" ACL for your Users)
Theme = "typeyoursharepath\typeyourtheme.theme"
Theme = """" + Theme + """"
'Open Display Properties Windows, Select your theme and apply with keep focus on Windows
ShellApp.ControlPanelItem cstr("desk.cpl desk,#Themes /Action:OpenTheme /file:" & Theme)
Wscript.Sleep 100
WsShell.SendKeys "{ENTER}"
While WsShell.AppActivate ("Display Properties") = TRUE
WsShell.AppActivate "Display Properties"
Wend
'In case of problem try to use a timeout value more important like "Wscript.Sleep 2000"
'END OF SCRIPT
'NOTES:
'APPLIED SUCCESSFULLY ON WINDOWS XP AND WINDOWS SERVER 2003R2 X86 AND UNDER CITRIX XENAPP 4.6FP7 (OS: W2003R2X86 SP2) TO APPLY WINDOWS EMBEDDED THEME WITH BLUE BACKGROUND COLOR MORE LIGHT.
'LOOKS GREAT ON CITRIX SESSION USER!
'INTEGRATED IN USER CONFIG GPO AT USER LOGON UNDER CITRIX XENAPP.

I don't think there is a native way to change Windows 7's (and windows 8's) theme silently, but you can try to use winaero theme switcher. you can read about and download it here.

Related

Detect and close "Windows Update" dialog box - vbscript .vbs file

I have the vbscript code to toggle between two windows:
Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WScript.Sleep 20000
WshShell.AppActivate("Inbox - Microsoft Outlook")
' WshShell.SendKeys "% r"
WScript.Sleep 20000
WshShell.AppActivate("Firefox")
' WshShell.SendKeys "% r"
Loop
The problem is, I get "Windows Update" dialog box randomly and it shows up on screen. Is there a way to find that dialog box and close it through existing vbscript that I have? Below is the picture of dialog box:
Appreciate any help.
Thanks,
Richa
I'm not sure if that dialog can be touched by VBScript unless you were to run it with admin privileges.
I think the easiest solution it to prevent Windows from automatically installing updates. Open up Windows Update from the Control Panel, go to Change Settings, then set it to one of
Download updates but let me choose whether to install them
Check for updates but let me choose whether to download and install them
If you choose the first one, I believe you'll get a taskbar notification (balloon) when there are updates available, which won't steal focus but still let you know updates are ready.
Given that Win7 is probably only going to receive Windows Defender definition updates for the rest of its lifetime, you probably won't encounter this dialog often now.

Script to Install Font in Windows XP

I am trying to install fonts in windows XP using a VBScript. But for some reason my script works fine in Windows 7 but does not work in Windows XP. I need to install fonts without a system reboot so, I had to choose this approach instead of other registry change approaches which would need a system reboot. Here is my VBScript
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("D:\Logs\")
Set objFolderItem = objFolder.ParseName("Roboto-Italic.ttf")
objFolderItem.InvokeVerb("Install")
My guess is the InvokeVerb("Install") command is not working in Windows XP. In that case are there any alternatives? Please guide me Thanks...
Next script (a code snippet) should work on (obsolete) Windows XP:
Const ssfFONTS = &H14&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ssfFONTS)
objFolder.CopyHere "D:\Logs\Roboto-Italic.ttf"
If the font is already installed then you could be prompted to overwrite it. Not sure whether or not reboot required using above approach...
See ShellSpecialFolderConstants enumeration
Specifies unique, system-independent values that identify special
folders. These folders are frequently used by applications but which
may not have the same name or location on any given system.
Among others:
ssfFONTS 0x14 (20). Virtual folder that contains installed fonts. A
typical path is C:\Windows\Fonts.
Read Hey, Scripting Guy! How Can I Install Fonts Using a Script?:
As soon as the font has been added to the folder, the operating system
will immediately install the font for you...
That’s true, but with one very important caveat: you must copy the
file using the Shell object. Admittedly, you can use WMI or the
FileSystemObject to copy a file into the Fonts folder; however,
when you do so the operating system will not automatically install the
font for you. As far as we know, the only programmatic way to get
Windows to recognize that a new font has been added to the Fonts
folder, and thus get Windows to install that font for you, is to use
the Shell object.

Invoke 'Open' Dialog from Windows Desktop

Is there some way I can programmatically (in VBS) OR by using CMD/RUN open the 'Open' dialog that contains the places bar and a browser but without opening say notepad or MSpaint?
http://i.technet.microsoft.com/dynimg/IC354177.jpg
I'd like to use this on the desktop itself, it would be really cool if there was a DLL I can just use instead of having a VBS file but if not i'm sure its possible in VBS.
I'm busy searching where the actual open dialog box comes from, it should come from some DLL file somewhere.
I might even consider stopping the windows shell from opening all together and just using this open window as the shell on some computers.
Regards, Rocklore
What version of Windows are you on?
"UserAccounts.CommonDialog" was the way to do this in XP. But it no longer exists in Windows 7. You may be able to use some of the flags available for the BrowseForFolder() method to make it look like a file open dialog. See this page for an example.
XP Edit:
Here's an XP example using UserAccounts.CommonDialog.
With CreateObject("UserAccounts.CommonDialog")
.InitialDir = CreateObject("WScript.Shell").SpecialFolders("Desktop")
.Filter = "All Files|*.*"
' Show the dialog. If [Open] is clicked, save the name of the selected file...
If .ShowOpen Then strFile = .FileName
End With

How can you have a dialog box displayed when opening a program in windows xp?

Does anyone know how to have a dialog box with a custom message pop up any time that a specific program is opened? The computer is running Windows XP Professional 2002 with Service Pack 3. The program is used to operate a scientific instrument that keeps getting damaged by lab users who disregard printed instructions around it. Ideally, I could have a dialog box pop up that requires users to click an "OK" button before the program opens. I've spent some time browsing the web for ideas, but have so far come back empty-handed. The program is usually opened from a shortcut on the desktop.
Many thanks,
Jeremy
A user on another forum answered this question for me. I created a small shell script (text file saved with .vbs extension) to display the dialog box when the program is opened from a Desktop shortcut targeting the script file.
Here's the link to the post in the other forum for more details:
The script that worked for me is shown below:
startupMessage = MsgBox("...close the lid gently and only use the button to open it.", 0, "To prevent instrument damage...")
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim cmd
cmd = "C:\Program Files\InstrumentApplication.exe"
cmd = chr(34) & cmd & chr(34)
WshShell.Run(cmd)

Modify XP theme (appearance&color scheme) from a vbscript

Does anybody know how to modify Windows XP appearance and color scheme using VBScript?
I have an application written in Visual C++ that needs Windows XP appearance (not classic) to be properly displayed and I want to set this properties from the Installation.
I use InstallShield to make the installer and VBScript to perform some custom actions. So it would be great if I can create a script in visual basic to change this properties.
This should do it:
rundll32 shell32.dll,Control_RunDLL desk.cpl desk,#themes /Action:OpenTheme /File:"%WinDir%\Resources\Themes\Luna.theme"
However you still need to get the user to click "OK" or use another utility to do this for you.
If you need to change individual appearance options (like window colors), you can modify the appropriate registry values under the HKEY_CURRENT_USER\Control Panel\Appearance and HKEY_CURRENT_USER\Control Panel\Colors keys. For example, this code will chamge the window background color to cream:
Set oShell = CreateObject("WScript.Shell")
oShell.RegWrite path & "HKCU\Control Panel\Colors\Window", "255 251 240", "REG_SZ"
Note, however, that Windows will probably apply the registry changes only after reboot.
If you need to load a ready .theme file, you can use the following code:
Const Theme = "C:\MyTheme.theme"
Set oShellApp = CreateObject("Shell.Application")
oShellApp.ControlPanelItem "desk.cpl desk,#Themes /Action:OpenTheme /file:""" & Theme & """"
Although, as sascha has pointed out, this will only bring up the Display Properties dialog with the specified theme selected; you still need the user to click OK or press Enter. It's possible to simulate key presses from script code using the WshShell.SendKeys method:
Set oShell = CreateObject("WScript.Shell")
' Wait until the Display Properties dialog is opened
While Not oShell.AppActivate("Display Properties")
WScript.Sleep 500
Wend
' Send the Enter key to close the dialog and apply the theme
Do
oShell.SendKeys "~"
WScript.Sleep 500
Loop While oShell.AppActivate "Display Properties"
But this approach is unreliable, because the user could click somewhere else so Enter would go to another window. Also, the Display Properties dialog caption is locale-dependent.
Another option would be to use the Theme.Manager API provided by the themeui.dll library starting from Windows XP SP1, but it doesn't seem to work on XP SP2. Anyway, you can find sample code here.
What I did was creating a c++ dll that I use as a Custom Action in Install Shield. In this dll I use the uxtheme.dll to set the luna.msstyle file as a theme. This is the function that does the work:
bool SetVisualStyle()
{
TCHAR szUxTheme[MAX_PATH+1];
UINT nSize = ::GetSystemDirectory( szUxTheme,
MAX_PATH);
szUxTheme[nSize] = '\0';
wcscat_s( szUxTheme,
MAX_PATH - nSize,
L"\\uxtheme.dll");
HMODULE hModule = ::LoadLibrary(szUxTheme);
if(!hModule)
{
return false;
}
typedef int (__stdcall *SETVISUALSTYLE) ( LPCWSTR szTheme,
LPCWSTR szScheme,
LPCWSTR szFontType,
int nReserved);
SETVISUALSTYLE pFnSetVisualStyle;
pFnSetVisualStyle = (SETVISUALSTYLE)GetProcAddress( hModule,
MAKEINTRESOURCEA(LOWORD(65)));
if(pFnSetVisualStyle)
{
pFnSetVisualStyle( L"C:\\WINDOWS\\Resources\\Themes\\Luna\\luna.msstyles",
L"NormalColor",
L"NormalSize",
1|32);
}
::FreeLibrary(hModule);
return true;
}
It's not perfect but it does what I need.
I hope that this can help someone else...if you have any doubt don't hesitate in asking me.
Cheers.
'Script name: yourtheme.vbs
'Object: Automate without command prompt the application of a Windows Theme by a VB script
'
'SCRIPT CONTENTS:
'Define Variables :
Set ShellApp = CreateObject("Shell.Application")
Set WsShell = CreateObject("Wscript.Shell")
'
'Define path for your file theme (put it on a network share and don't forget to apply "read and execute" ACL for your Users)
Theme = "typeyoursharepath\typeyourtheme.theme"
Theme = """" + Theme + """"
'Open Display Properties Windows, Select your theme and apply with keep focus on Windows
ShellApp.ControlPanelItem cstr("desk.cpl desk,#Themes /Action:OpenTheme /file:" & Theme)
Wscript.Sleep 100
WsShell.SendKeys "{ENTER}"
While WsShell.AppActivate ("Display Properties") = TRUE
WsShell.AppActivate "Display Properties"
Wend
'END OF SCRIPT
Applied successfully on Windows XP and Windows Server 2003R2 X86, and under Citix XenApp 4.6FP7 (OS: W2003R2X86 SP2) to apply Windows Embedded theme with blue background color more light.
Looks great on Citrix session user!
Integrated in user config GPO at user logon under Citrix XenApp.

Resources