Script to add Windows Gadget to user profile (VBScript)

Introduction

This PowerShell script demo illustrates how to add windows gadget to user profile.

Scenarios

This question is asked by users in the TechNet forum. They just want to add windows gadget to user profile.

Script

Step1: Double-click the script or you can drag a text file to the script. The content of text file should be like the following.

Drag the file to script.

Then it will show some messages about the results, if it cannot connect to the computer.

After all operations done, it will show a message.
 

Note

1. At first of all, you should add the gadgets to the current user, and then you can execute the script.

2. You may need to reboot or log off of windows for the change to take effect.

3. And by default, the sidebar process is not started. So in the first time you should start it manually: Right click on the desktop->Gadgets. Then you can see the Gadgets you have set.

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

VB Script
Edit|Remove
SelectCase wsArgNum 
        Case0  
            CompName = objshell.expandEnvironmentStrings("%Computername%") 
            CopySidebarProfile(CompName)      
        Case1Dim InputText  
            InputText = WScript.Arguments(0) 
            Dim objFSO,File 
            'Create "Scripting.FileSystemObject" objectSet objFSO = CreateObject("Scripting.FileSystemObject")  
            Set File = objFSO.OpenTextFile(InputText,1) 
            'Get the computername in the text fileDo Until File.AtEndOfStream 
            CompName = File.ReadLine 
            CopySidebarProfile(CompName) 
            Loop 
            File.Close 
        CaseElse  
            WScript.Echo "Please just drag one txt file to the script"EndSelect

Prerequisite

Windows 7

Additional Resources

Related forum threads:
http://social.technet.microsoft.com/Forums/en-US/officeappcompat/thread/359e52a2-a641-490f-8f49-6efdd604a079 
http://social.technet.microsoft.com/Forums/en-US/officeitpro/thread/a3db722c-53e2-4473-8782-b80c586447d1/