Yes, all those things can be
automated. And I'm feeling extra techy today, so I'm going to go ahead and write this script with you and share some scripting love. The first thing you should know, if you don't already know it, is that a script is nothing but a bunch of command line commands saved with the
.bat extension. However, to be effective, you do need to read the commands and learn them.
Also, please note that the script you want to write is fairly complex, so I'm not going to write it for you. But I will assist you with it and will answer each question or problem, if you really want to put in the work.
I'll address each item you've listed in turn, but let's cover some foundational stuff first.
Since you already know that for your script to run you need to save it with the
.bat extension, here are some other things to know.
1) For any command, type the command name and
/? to get more info about it. Example
IF /? is going to print out a big help file on how to use the
if command.
2) User either
REM (with at least one space character after that word) at the beginning of a line, or use the double colon
:: at the beginning of a line to mark a line as a comment. A
comment is simply like a note to yourself. It won't be parsed by the command interpreter and won't be executed when the script runs. It's just a way for you to organize your content, or remind yourself what a certain section of code is doing.
Code:
:: Navigate to the System32 drive, list all files and print files that start with vtt
cd "C:\Windows\System32
Dir /B /S C:\vtt*
:: This code features the [B]DIR[/B] command which tells Windows to list all the files in
:: The current directory. It also features the [B]CD [/B]command, which is how you
:: [B]C[/B]hange [B]D[/B]irectories
:: The [B]/B [/B]and [B]/S[/B] are called switches, also known as options, and they allow you
:: to perform other actions with the command. The [B]/B [/B]switch tells windows to print
:: the full path of the file, not just the name of the file. The [B]/S [/B]switch tells windows
:: to also search inside any folders it finds within the System32 folder.
2) You should download
NotePad++. This is like notepad on steroids, and it will automatically color code your batch file commands for you. For instance, it will place comments in green, labels in in RED, etc. This make it a lot easier to spot a mistake.
It also has a billion other useful commands when working with text of any kind.
3) When you are writing out a path with spaces in it, such as C:\Windows\All My Files, you need to remember to wrap that Path name in quotes, otherwise windows will tell you that it can't find the folder.
Code:
:: Proper way to write path
"C:\Windows\Sysmtem32\What A Lot Of Spaces In A Folder\Hereismyfile.txt"
::Bad way to write path
C:\Windows\Sysmtem32\What A Lot Of Spaces In A Folder\Hereismyfile.txt
Disclaimer: I've been writing scripts and working with windows for a long time, but I just migrated to windows 7, and so I'm still catching up on some of the changes. Keep in mind that I may refer to a path like
My Documents, which I know is now just called
Documents in Windows 7, but old habits are hard to break.
Ok, so let's start to look at your requirements and how we can accomplish them in a batch script.
1) Desktop Items
There are really two things to note when it comes to configuring the desktop.
1. Use
vLite, which is the
Vista / Windows 7 version of
nLite to configure your environment. nLite /vLite software will let you set up everything you want about your system, including what items you want on the desktop, what services you want to uninstall, what updates, service packs, or hotfixes you want to include, etc. When you're done you can burn an unattended install DVD or CD-ROM and have a ready to go image for deployment. You can also add scripts to be ran after the install, and it will sign you into whatever account and run the scripts for you.
What they don't do, sadly, is let you simply place certain shortcuts on the desktop. But they do let you run scripts. So, long story short, what you want to do write a script to either detect if a shortcut exist, and if not place it on the desktop.
Note that when you copy your shortcuts to the vLite folder of your choice, you want to use environment variable paths, and not explicit path names. In other words, I can use the environment variable for a user's directory like this
%USERPROFILE% and that refers to the PATH
C:\Users\{username}. So I don't need to know the name of the user, I just need to use the variable called
%USERPROFILE% with a
\Desktop to reach their desktop. Code example below:
Code:
:: Creating a shortcut on the user's desktop, only if it is not there already.
CD "%USERPROFILE%\Desktop"
IF Exist Shortcut1.lnk ( echo The file Shortcut 1 already exist ) Else ( xcopy "E:\I386\CustomFiles\Shortcuts\Shortcut1.lnk" "%USERPROFILE%\Desktop\Shortcut1.lnk )
::Creating shortcut 2
CD "%USERPROFILE%\Desktop"
IF Exist Shortcut2.lnk ( echo The file Shortcut 2 already exist ) Else ( xcopy "E:\I386\CustomFiles\Shortcuts\Shortcut1.lnk" "%USERPROFILE%\Desktop\Shortcut1.lnk )
::The [B]IF [/B]and [I]optional [B]Else [/B][/I]command is used to test if a condition is true or not. It can also compare ::the relationship between something, as in one number be greater or less than
::another. It has a lot of functions, so definitely read up on it.
:The [B]echo [/B]command is used to print strings (or text) to the standard output
::And the standard output in this case is the command line window.
::The [B]xcopy [/B]command is used to copy files from a source to a destination
::The basic format of the command is [B]xcopy [/B]source destination
::Where the source is the path of the file/ directory you are copying and the
::Destination is where you are copying it to.
Configuring the task bar and notifications can be done through
vLite and
disabling Aero can also. If you want to configure services, you need to use the
SC command, which stands for
Service Controller.
START MENU:
Show 8 programs
Show only DOCUMENTS, COMPUTER, CONTROL PANEL and RUN on the right side.
All of that can be done in vLite.
In scripting, things always come down to three ways of changing settings. Either you need to
run some commands,
Edit the registry, or
copy a custom file to a certain folder. Now, I don't have enough energy to list where all these things in the registry would be, but I'll provide one example and then afterward you just need to start Googling for things like
"Where are the task bar settings located in the registry?"
Windows 7 Task Bar Settings In Registry:
Have a look at this article here
Now, I know some people are worried about editing the registry. You don't strike me as that type, but if you are, then you might as well stop reading right now. But if you want to really learn Windows, and how to automate everything, then you'll need to become familiar and comfortable with it. But you'll love the fact that you did.
It is important to do a backup of your registry, but you don't need to backup the whole thing. Each time you edit a key (any folder) just right click it and do a backup, if something goes wrong (which it almost never does) then do an import and it will overwrite whatever you did.
Ok, so there is a command line tool for editing the registry. It's called
Reg. Some example commands would be: To query for the existence of a key
REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
or to add a key to the registry
REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
There are many switches that you can use with the
REG command, so definitely read the article first.
The thing about the
reg command, and others like it, is that to really be effective, you need to be able to parse (look through) the output of a command and then do something with that data. If you run
ipconfig in the command line, for instance, you will get your IP address, but you would get a bunch of other data too.
If you needed to write a script that used
ipconfig to get the user's
IP address only, how would you do that? You'd have to parse through that output, find the ip address, and place it a container of sorts. And you can do all this with the command line.
Getting back to the
REG command for a moment, If you run the
reg query command above, the command line would spit out something like this
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
NoDriveTypeAutoRun REG_DWORD 0x91
NoViewContextMenu REG_DWORD 0x0
NoSetTaskbar REG_DWORD 0x0
NoSaveSettings REG_DWORD 0x0
Just like with
ipconfig, we need to be able to grab just one piece of data, in this case a particular key, like the
NoViewContextMenu item, and determine if it is set to 0x0 or 0x1. Now how could you do that? You'd have to use the
FOR command.
It's not hard to use, but it does require that you read about it carefully.
I suggest you read up on it, and then respond to this thread with questions, and I'll get you up to speed on it. Once you know the
REG command and once you know how to use the
FOR command to find any value within the registry (or within anything else for that matter) , you can go crazy editing the hell out of windows, and custom scripting basically whatever you want. But again, vLite is going to take a lot of that work and do it for you, so if the option is in vLite, I would just do it there.
OTHER SETTINGS:
Disable system restore on all drives
Move page file from disk 1 to disk 2, or partition 2.
Disable some visual effects from system properties
Disable Allow remote assistance
Turn off user access control
Again, all through vLite, and some through the registry. Pagefileconfig is a command line tool, so you don't need to edit the registry.
CONTROL PANEL & ACTION CENTER
Disable ALL notifications (security, maintenance, etc)
Disable windows update
Edit some power config options
Notifications and Windows Update are definately in vLite. Power Config actually has to be done in the registry.
OTHER
Set D:\ (partition 2 or disk 2) as the default "documents" path
You can use the SET command to explicitly declare the default documents path for any environment variable, including the documents path.
Okay, so at this point, its all up to you. You should start working on a script, and whenever you get stuck or have a question, just update this thread with your question and I'll answer it for you. If were lucky then some other scripters might join in and increase both our knowledge
