Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply a theme from command prompt ?? 1

Status
Not open for further replies.

Lurky

IS-IT--Management
Oct 31, 2003
64
GB
I'm trying to create a logon batch file that will enable us to apply a windows theme when users log on, the only problem is, when we run the *.theme file, we have to click OK or APPLY. Is there any way of running the *.theme file silently? i've tried using a command prompt and using "start /b Lurky.theme" but it still opens the display properties window and waits for me to click OK or APPLY.

"Experience is the result of failure
 
I do not know how familiar you are with WSH scripting. The Themes command line calls the associated file extension like this (I have fully pathed the command):

%windir%\system32\rundll32.exe %windir%\system32\Shell32.dll,Control_RunDLL %windir%\system32\desk.cpl
desk,@Themes /Action:OpenTheme /File:"%1"

If there is a valid filename used for %1, it is substituted and highlighted waiting for an OK.

. You could use SENDKEY to answer the prompt
. You can use the excellent freeware AutoIt to roll the whole thing together in the alternative:
 
I've never heard of WSH Scripting!

I tried to use sendkey, however, the sendkey command runs before the Display properties window has a chance to open. Also, it opens the Sendkey program as well as sending the OK command.

What we'd like is a completely silent way to apply a set theme on the pc's when a user logs on. The old Network Manager set policies that we can't get rid of, therefore when a user logs on, we get classic windows. We need something that runs on login and sets a new theme.

"Experience is the result of failure
 
WSH is the native XP installation of the "Windows Scripting Host." This allows you to script in VB or Java as an alternative to .bat or .cmd files. It has a native sendkey and RUN facility in either language.

You would run the first statement, and sendkey to the application to OK or Apply as needed.

Given the details I provided earlier, this is a simple script to enable and include at logon. I apologize as I myself will likely not be able to look at this until late tonight, but if you check the forum again either myself or some of the scripting wizards will reply. Or, post the question and the link back to here in forum329
 
Note to anyone attempting to script this:

add before the sendkey:

WSH.Sleep 1600 ' wait for desk.cpl to initialize
 
On the same subject when I start the computer I get a choice of what operating system do I want to use Windows XP or Microsoft Windows if I don't respond it will start after 30 secs with Win XP, but it does wait for my response to press enter every time. I tried to edit Boot.ini in Sys Config Utility but it won't let me, is there anywhere else I can edit the sys boot? By the way I did a fresh install of winXP namely formatted the drive before installing XP.
Thanks
Nick
 
right-click My Computer, Properties, Advanced, Startup and recovery options - Settings, Edit.

Set in edit mode the default timout to 0.
 
bcastner
Re: Win XP boot, Yes it worked Thank You.
Nick
 
[tt]
' logon script to set the Theme
' make this the last logon entry
' make sure logon is processed syncrhonously through Group Policy **
' edit YOUR_THEME_HERE to a fully pathed theme

Const iFocus = 1

'open the Shell
Set objShell = Wscript.CreateObject("Wscript.Shell")

' now call Rundll32, and demand focus for the later Sendkeys
objShell = "rundll32.exe Shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /File:"YOUR_THEME_HERE"", iFocus

'pause for the desk.cpl to initialize
Wscript.Sleep 1600

'send the confirmation to the control panel desk applet
objShell.Sendkeys "{ENTER}"

' ... end of script

[/tt]

I have not tested this, but this is the gist of what you requested.

** XP by default processes logons asynchronously. Change this though Group Policy. See last paragraph of my faq779-4017 for instructions.





 
When it comes to scripting, i'm clueless!!

I attempted to use Autoit and pasted the scipt into it, changed the theme for the path of the theme i use and it just came up with multiple errors when i ran it.

What exactly should i be doing with this script?

"Experience is the result of failure
 
I apologize, as this thread disappeared from my display.

AutoIT has it own scripting language. What I wrote above I intended you to:

open a notepad session, and create something like themes.vbs, and copy paste the above

A .vbs or other script file should launch in a logon script, or use if part of a larger command session the syntax:

wscript themes.vbs

 
Here's the code I wrote using AutoIT to restore the Windows Classic Theme to a workstation. After you compile, add START \\uncpath\Scriptname.exe to the last line of your logon script.

;AutoIT Script to Restore Windows Classic Theme to Users Desktop
;Created by GSpino12/17/2004
;XPClassicTheme.au3
;==============================================
IF @OSVersion <> "WIN_XP" THEN
MsgBox(0,"Error","You must be running Windows XP to run this utility")
Exit
ENDIF

Dim $var1 = '"' & @WindowsDir & '\'

;launch control panel applet to change desktop theme
Run(@ComSpec & " /c " & 'rundll32.exe Shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /File:' & $var1 & 'resources\themes\windows classic.theme"', "", @SW_HIDE)

;wait for Disply Properties window to open, timeout after 3 sec
WinWait("Display Properties", "",3)

;send Enter to open applet
Send("{ENTER}")

;Exit application
Exit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top