ki_supergeek Posted February 9, 2008 Posted February 9, 2008 (edited) Hello everyone....!I'm trying to load the Royale.msstyles desktop theme file as part of my XP Pro unattended install and could use a fresh set of eyes to help fix a problem that's been driving me nuts searching for a solution that works every time.I found this vbs script file on the web and modified it to load the Royale.msstyles file, and then use sendkey to press Enter and apply the theme as follows:Dim WshSHellset WshShell = CreateObject("WScript.Shell")WshShell.Run("Royale.msstyles")WshShell.AppActivate("Display Properties")WshShell.SendKeys("~")This script resides and is being called from C\Windows\Resources\Themes, and it runs fine by itself every time. However, when it is called from inside a batch, exe, or cmd file, the sendkey is intermittent and doesn't always work which requiries manually pressing the enter key to apply the theme.I have tried creating an exe file with Winrar that works fine by itself, but again, the sendkey function doesn't work when the exe file is called from RunOnceEx.I've tried using cscript, Wscript, and start to call the vbs file in various cmd and bat files with the same results where they work fine alone, but not when called by another process.I've also tried using the sleep command with different timings to delay the sendkey function within the vbs with inconsistant mixed results.The only thing I can figure that may be causing the problem is the windows sendkey function isn't always available or being found when the script file runs?This seems to be a simple task to automatically "press" the enter key, but making it work consistantly has been a royal pain. I plead my case and appeal to the guru's on MSFN to please help me solve this one!Any help or suggestions on how to fix this would be greatly appreciated!Thanks in advance.....!EDIT: Further research has found that the Sendkeys function is not consistantly reliable by nature and is not recommended for use in certain applications such as this, so I'm using a different approach to apply the theme style. Edited February 10, 2008 by ki_supergeek
MHz Posted February 10, 2008 Posted February 10, 2008 I've also tried using the sleep command with different timings to delay the sendkey function within the vbs with inconsistant mixed results.Sendkeys is somewhat primative in operation. You could make use of AutoItX.dll (used from your VBScipt) or AutoIt3 to help automate it much more reliably. AutoItX.dll can be found in the AutoIt3 installation.This is a way to wait for the window to activate if you still want to use SendKeys. The function will wait for up to 5 seconds when called.Dim WshSHellSet WshShell = CreateObject("WScript.Shell")On Error Resume NextWshShell.Run("Royale.msstyles")If WinWaitActive("Display Properties", 5) Then WshShell.SendKeys("~")End IfFunction WinWaitActive(text, timeout) Dim timediff, timestart, timestop timestart = Timer Do timestop = Timer timediff = timestop - timestart If timeout And timediff > timeout Then Exit Function End If WScript.Sleep 250 Loop Until WshShell.AppActivate(text) WinWaitActive = TrueEnd Function
helo Posted February 10, 2008 Posted February 10, 2008 Might wanna try this. The sleep command gives the Display properties some time to open before the enter key is pressed. Also the .Run command comes after the .AppActivate.Hope it works for you.Dim WshSHellset WshShell = CreateObject("WScript.Shell")WshShell.AppActivate("Display Properties")WshShell.Run("Royale.msstyles")WScript.Sleep 5000WshShell.SendKeys "{ENTER}"
Methanoid Posted May 9, 2008 Posted May 9, 2008 HeloI am confused... I've been searching for advice on this. I have two VBS scripts that are on my desktop after an unattended install, called AutoArrangeIcons.vbsQuicklaunch.vbsHow can I have Windows automatically run them? I have a final Cleanup.cmd file - can I just type Quicklaunch.VBS in that or do I need to use something else? Sorry to ask but I've searched and not found the answer!!!
joe43wv Posted May 9, 2008 Posted May 9, 2008 You can try placing those files in the startup config in the registry.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now