Script to Install Font in Windows XP - vbscript

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.

Related

Can I run a script automatically after Outlook finished startup?

I want to set the message signature automatically each time Outlook starts. Unfortunately, the classic approach using Application_Startup() doesn't work for this. It seems that the objWord.EmailOptions.EmailSignature object is not yet available at this stage of application startup.
Is there a way to execute the script, after Outlook finishes startup?
Private Sub Application_Startup()
Set objWord = CreateObject("Word.Application")
Set objSignatureObjects = objWord.EmailOptions.EmailSignature
objSignatureObjects.NewMessageSignature = "Internal"
objSignatureObjects.ReplyMessageSignature = "Internal"
End Sub
The signatures are being kept as separate files in the Signatures folder. You can find this folder in the following locations:
Windows XP
C:\Documents and Settings\%username%\Application Data\Microsoft\Signatures
Windows Vista, Windows 7, Windows 8 and Windows 10
C:\Users\%username%\AppData\Roaming\Microsoft\Signatures
To see this folder you must have View hidden files and folders enabled or you can simply copy and paste the above paths in the address bar in Explorer to directly open the folder.
At any point in time, you may go there and edit them - deleting, adding, changing and etc.

VBScript won't move some files

I have written a VBScript that helps me organise my desktop every time it gets messy.
It works fine it moves my files and shortcuts based on the extension and the name of the app. However, I have a few app shortcut links that just won't move. in fact the vbs script will not even see them with this basic script
Set FSO = CreateObject("Scripting.FileSystemObject")
dir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
Set folder = FSO.GetFolder(dir)
Set files = folder.Files
For Each file in files
MsgBox file.Name
Next
The files in question are all shortcuts they are iTunes, VLC, Google Chrome and WinRar.
Is there anything I can check to see why vbs won't even see these files?
What You can see on your desktop is hybrid view of two folders:
C:\Users\YourUsername\Desktop
C:\Users\Public\Desktop
Where the Public one is usually a place, where shortcuts are being created during app install, so all users do have them. In your script You are only looking for files in the YourUserName\Desktop, that's why the script does not see those shortcuts.

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 to change the path for "run command" "notepad"?

Where is in the registry the path executed when I run the "notepad" command in windows "Start->run command" interface? I want to change it for notepad++ (it is required so, although could look not really good)
If you are like me you use windows run command all the time. I hate using the mouse to point and click a shortcut on the start menu. WIN-R are probably the two most over used keys on my keyboard. After thinking about if awhile I hunted down how the run command works. It turns out that it makes a call to ShellExecute, which I guess is not too surprising. The next thing I wanted to find out was exactly how the commands are resolved. The following is an ordered list of how they are resolved ([1]):
The current working directory
The Windows directory (no subdirectories are searched)
The Windows\System32 directory
Directories listed in the PATH environment variable
The App Paths registry key
Naturally the next thing I wanted to do was customize existing commands or add new commands so I do not have to type as much (standard lazy approach). After examining my options which were to put the executable in one of those paths (since it only locates executables and not shortcuts), modify the path environment variable or add a key to App Paths. The App Paths option seems to be the easiest and most flexible to me. Here is a layout of what you need to do to add an App Paths entry ([1]):
HKEY_LOCAL_MACHINE-->
SOFTWARE-->
Microsoft-->
Windows-->
CurrentVersion==>
App Paths-->
file.exe-->
(Default) = The fully-qualified path and file name
Path = A semicolon-separated list of directories
DropTarget = {CLSID}
Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. I cannot guarantee that problems resulting from modifications to the registry can be solved. Use the information provided at your own risk.
The minimum needed to add a new entry is to add the key file.exe where file is the string you want to type into the run command and to add the Default entry which is the fully-qualified path to the file you want to execute. Note that even it the file you are going to reference isn't an exe file you still need to put the .exe on the key. Here is a sample registry file that I created to add a shorter keyword for Internet Explorer:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\ie.exe] #="C:\Program Files\Internet Explorer\iexplore.exe"
After entering that entry into the registry I can simply type “ie” at
the run command to open internet explorer.
Here is a list of some common commands I use at the run command:
cmd – Command prompt winword – Microsoft Word excel – Microsoft Excel
outlook – Microsoft Outlook iexplore – Internet Explorer firefox –
Mozilla Firefox notepad – Notepad compmgmt.msc – Computer Management
Console control appwiz.cpl – Add/Remove programs dialog mstsc –
Microsoft Terminal Service Client regedit – Registry Editor
…
If there is some program that I find myself using all the time I figure out what the run command is for it and if there is not a short easy one I add one to my App Paths as described above. Does anyone else have some other common run commands they use?

Change theme in Windows XP or Windows 7 (silently)

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.

Resources