Click here to Skip to main content
Click here to Skip to main content

47 Useful Windows Vista Command-Line Utilities

By , 25 Jan 2009
 
Prize winner in Competition "Best VB.NET article of January 2009"
VistaCommands

Introduction

Have you ever tried to find a specific app in Vista, and when you did find it, how many mouse clicks did it take you to get there? 2, 3,...10? how many? If this has happened to you, then this is what you need. This app has 47 of the most commonly used command line functions(Example: RunDll32.exe, shell32.dll, Control_RunDll, appwiz.cpl, 0). This brings up the Add/Remove Programs dialog form. Copy and Paste this in your Start, Search box (and press the Enter key) to see what happens.

Typing these command lines and using multiple mouse clicks gets a little tiresome when trying to get to a specific point in the Vista arsenal of apps. So, I put all 47 commands in button click events.

Background

This program is not what I had intended. I was searching the net for a list of .NET DLLs and all their functions when I came across this site which can be viewed here. This site has a few tips-n-tricks and the 47 command lines that I use in the program.

All the command lines use 'RunDll32.exe' as a starting point, then the arguments list follows. The arguments consist of a few *.dll and *.cpl files that are all located in the 'C:\Windows\System32\' folder.

Problems... Always Problems

The first and only problem I came across was 'How do I execute these command lines in a button_click event?' I am not well versed in VB, but, I am learning. After a few failures and racking my brain, I decided to check out the Process Component in the tool box. I searched the properties and saw the 'Arguments, FileName, and Working Directory properties.' This was everything I needed to execute the command lines. The code is given below:

Public Class frmUtilities
    Inherits Form
    Dim fileArgs As String
    Dim path As String = "C:\Windows\System32\"

    Private Sub btnAddRemove_Click(ByVal sender As System.Object, ByVal e As 

System.EventArgs) Handles btnAddRemove.Click
        fileArgs = "shell32.dll,Control_RunDLL appwiz.cpl,,0"
        cmdProcess.StartInfo.Arguments = fileArgs
        cmdProcess.StartInfo.WorkingDirectory = path
        cmdProcess.StartInfo.FileName = "RunDll32.exe"
        cmdProcess.Start()
        cmdProcess.WaitForExit()
        Me.Focus()
        Me.Show()
    End Sub

    Private Sub btnContAdvisor_Click(ByVal sender As System.Object, ByVal e 

As System.EventArgs) Handles btnContAdvisor.Click
        fileArgs = "msrating.dll,RatingSetupUI"
        cmdProcess.StartInfo.Arguments = fileArgs
        cmdProcess.StartInfo.WorkingDirectory = path
        cmdProcess.StartInfo.FileName = "RunDll32.exe"
        cmdProcess.Start()
        cmdProcess.WaitForExit()
        Me.Focus()
        Me.Show()
    End Sub
    'Continues on
    'with the rest
    'of the 47 button-click events.
End Class 

CAUTION

All the Delete button click events 'DO NOT' bring up any dialog windows. They start automatically. Be careful when using these click events. Make back-ups of all your files and stuff you will want to keep. An ounce of prevention... you know the rest.

WINDOWS XP USERS: You will have to do some digging on your own to find the correct '*.cpl' files to use in some of these. Vista uses 'inetcpl.cpl' and XP might use 'inet.cpl'. I'm not sure about the exact file name so do some research on this subject before use.

UPDATES

I just added some message boxes for the delete buttons giving you a choice to delete or not to delete. I also fixed the Internet Options fileArgs to work correctly and I disabled the Open With button because it had no use in this program. Special thanks goes to Hans Dietrich for his idea on the message box implementation.

History

  • 25th January, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

rspercy65
Retired
United States United States
Member
I am currently retired.
I have no degree but I have some programming experience
when I was in college(Cobol, Pascal).
 
My accomplishments thus far are;
Best VB.Net article for January(2009)
Best VB.Net article for July(2009)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5membermanoj kumar choubey24 Feb '12 - 2:05 
Nice
GeneralNo action at 'Display settings'memberdherrmann27 Mar '09 - 12:02 
Hi,
I tried your program, but 'Display settings' doesn't function.
Are there for Vista other parameters?
I wanted to go to the window control panel-adjustment-display, but when I use the button nothing happened.
 
regards-
Dietrich
GeneralRe: No action at 'Display settings'memberrspercy5827 Mar '09 - 14:03 
Add these three lines under Class frmUtilities
 
Public Declare Function WinExec Lib "kernel32" Alias "WinExec" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long
Public Const SW_NORMAL As Long = 1
Dim strSysPath As String = Environment.GetFolderPath(Environment.SpecialFolder.System)
 
Then goto the btnDisplaySettings_Click() event and remove the contents inside and replace it with this...
 
WinExec(strSysPath & "\control.exe desk.cpl,Settings,@Settings", SW_NORMAL)
 
THNX for pointing this out...
 
Hope this helps
 
Regards
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralRe: No action at 'Display settings'memberdherrmann27 Mar '09 - 22:15 
Oh, thank you very much for the very fast answer!!
It functions now.
 
Can you tell, what other parameters you can use at:
...desk.cpl,............
 
And have you any idea, how I can program, that a secondary screen, numbered '2', should be moved from the right side of the desk to the left side?
(this I need, because Vista doesnt hold this setting!)
 
regards-
Dietrich from Salzburg/Austria
 
PS. I saw, that you are retired and learn about VB. Great idea! I'm not retired yet but of the good vintage of 1948... Wink | ;-)
GeneralRe: No action at 'Display settings'memberrspercy5827 Mar '09 - 22:55 
Give me your e-mail address and I'll send you an extensive list on all the control panel applets
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralNicememberJared James Sullivan16 Mar '09 - 11:49 
Nice article with Windows 7 now in beta. Consider putting filename and arguements in .Tag property of button...
 
cmButton001.Tag = "rundell.exe|param1, param1"
 
then you have generic handler like so.
 
cmButton001_Click (..) Handles cmButton001.Click,cmButton002.Click,cmButton003.Click,cmButton004.Click
 
dim s() as string
 
s=sender.tag.tostring.split("|")
p.filename= s(0)
p.arguements=s(1)
 
Also, try some groupboxes, they are in tool box.
GeneralRe: Nicememberrspercy5816 Mar '09 - 13:55 
Have already done that. The article is in the February VB.NET Best Article.
"Access Control panel Apps in 2 clicks". I have also re-did this program with a Lisview and some buttons in a scrolling Panel. I also did it in a system tray utility. I have not put them on CodeProject as of yet. I am currently working on a DirectX AVI Player.
 
THNX 4 The Comment
Regards, rspercy58
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralGood Article -some advicememberTino123 Feb '09 - 20:30 
Did you code each button click event? You could have used one event to handle all the button click events. The handles clause at the end of a sub caters for this.
i.e
 
Private Sub btnAddRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddRemove.Click,Handles btnContAdvisor.Click
if sender.name = "btnAddRemove" then
fileArgs = "shell32.dll,Control_RunDLL appwiz.cpl,,0"

ElseIf sender.name = "btnContAdvisor.Click" Then
fileArgs = "msrating.dll,RatingSetupUI"
 
...
End if
 
cmdProcess.StartInfo.Arguments = fileArgs
cmdProcess.StartInfo.WorkingDirectory = path
cmdProcess.StartInfo.FileName = "RunDll32.exe"
cmdProcess.Start()
cmdProcess.WaitForExit()
Me.Focus()
Me.Show()
End Sub
 
Then in one sub you all you would have to do is change the 'fileArgs' value. sender.name would give you which button was clicked.
GeneralRe: Good Article -some advicememberrspercy5824 Feb '09 - 0:36 
I just tried this, It cuts out a lot of code. Works great. THNX. I am new to VB, only been programming on and off for about 6 - 7 months now and am learning as I go. Once again, A BIG THANK YOU.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralVery Educantionalmemberpennyjp22 Feb '09 - 0:56 
Didnt know some of these existed. Keep up the good work.
Generalgood articlememberDonsw19 Feb '09 - 14:40 
Good work, keep them coming.
 
cheers,
Donsw
My Recent Article : Optimistic Concurrency with C# using the IOC and DI Design Patterns

GeneralNew Control panel app is complete.memberrspercy5828 Jan '09 - 12:17 
I just finished a new version of this app with a new UI. It has a MDI Parent form w/ 6 MDIchild forms categorized. The first 5 forms are the most commonly used apps and the CompleteList form Is a complete list of all the control panel apps. I cant upload it as it exceeds the upload limit. It is 8.18 meg in size because of all the jpeg files that are used in picture boxes.
 
If you would like to examine it, please leave your e-mail and I will upload it to you.
 
THNX everyone for such a good response to this article, over 4000 views in 4 days.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralHardcoded System PathmemberTapsnapper28 Jan '09 - 7:10 
Hi. Nice program. I have one issue though that you may want to address; you have hardcoded the path to the windows system directory. This is ok if the user has indeed installed windows on the C: drive. However, in the case of a dual boot configuration it cannot be guaranteed that the system folder will reside on C:. I have a threeway boot configuration of XP, Vista, and Windows 7beta, all on different partitions.
 
There is an article at this URL http://vbnet.mvps.org/index.html?code/system/windirs.htm[^] that explains how to obtain the current system folder path. Please do not think that I am trying to insult your intelligence if you already know how to find the system folder.
 
I was always told that whenever I wrote program code "never assume anything with regard to the users' setup configuration as there will always be one user who has altered their configuration from the norm."
GeneralRe: Hardcoded System Pathmemberrspercy5828 Jan '09 - 7:33 
I think I know what you are talking about. Code would look something like this...WinExec("%windir%\system32\control.exe ........", SW_NORMAL)
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralRe: Hardcoded System PathmemberTobiasP29 Jan '09 - 9:43 
I do not use VB myself, but it appears to me that the method used in the linked article is for pre-VB.NET versions of the language (it was originally written 12 years ago) while the project in this article is a modern VB.NET project. In VB.NET, I assume Environment.GetFolderPath(Environment.SpecialFolder.System) is the most simple way to retrieve the path to the system folder.
GeneralRe: Hardcoded System PathmemberTapsnapper29 Jan '09 - 11:05 
Yes, you are correct. I have just tried your method and it works fine. I'm relatively new to VB.net and consequently didn't know the environment class existed.
GeneralRe: Hardcoded System Pathmemberrspercy5829 Jan '09 - 12:51 
I am creating a new version with all control panel apps in it. I have the most used categorized and the last one is all the apps. I will have to try this.
THNX for the tip.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralRe: Hardcoded System PathmemberTapsnapper30 Jan '09 - 4:04 
If you use this code Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.System) inplace of Dim path As String = "C:\windows\system32\" this will solve the potential hardcoded path problem.
 
One other thing I noticed in your code that is unnecessary is in your msgbox answer code. You are converting an integer return value to a string ans = CStr(MsgBox("Are you sure you want to delete these files?", MsgBoxStyle.YesNo, "Ready to Delete Files?")) and then converting that string to a double to check the return value; If CDbl(ans) = vbYes Then
 
This isn't needed. the easiest way to do this is either to declare ans as an integer because that is what the msgbox function returns and compare this to vbYes; see this link http://msdn.microsoft.com/en-us/library/139z2azd(VS.80).aspx[^] Or to do an explicit comparison without declaring the ans variable.
 
So your code would look like this in the first example
 
Dim ans As Integer
....
....
....
 
Private Sub btnDeleteTIF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteTIF.Click
ans = MsgBox("Are you sure you want to delete these files?", MsgBoxStyle.YesNo, "Ready to Delete Files?"))
If ans = vbYes Then
fileArgs = "InetCpl.cpl,ClearMyTracksByProcess 8"
cmdProcess.StartInfo.Arguments = fileArgs
cmdProcess.StartInfo.WorkingDirectory = path
cmdProcess.StartInfo.FileName = "RunDll32.exe"
cmdProcess.Start()
cmdProcess.WaitForExit()
 
Me.Show()
Else
MessageBox.Show("Process Cancelled!")
Exit Sub
End If
End Sub
 

 
in the second example you can do an explicit comparison using
 
Private Sub btnDeleteTIF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteTIF.Click
 
If MsgBox("Are you sure you want to delete these files?", MsgBoxStyle.YesNo, "Ready to Delete Files?") = vbYes Then
fileArgs = "InetCpl.cpl,ClearMyTracksByProcess 8"
cmdProcess.StartInfo.Arguments = fileArgs
cmdProcess.StartInfo.WorkingDirectory = path
cmdProcess.StartInfo.FileName = "RunDll32.exe"
cmdProcess.Start()
cmdProcess.WaitForExit()
 
Me.Show()
Else
MessageBox.Show("Process Cancelled!")
Exit Sub
End If
End Sub

 
There is also no need for the Exit Sub statement in the Else clause. The Sub will be exited after the Messagebox.Show statement anyway. You would only need the Exit Sub if you were doing more processing after the Endif statement and didn't want this to be processed once the logic was inside the else clause.
 
Regards, Paul
GeneralRe: Hardcoded System Pathmemberrspercy5830 Jan '09 - 5:01 
THNX. I am fairly new to VB. I have been programming for about 6 months now. I am learning by doing as I dont have any books on the subject. I visit this site quite often for info.
 
I have redone the program and I implimented the Environment.GetFolderPath(...) in the program and it added 3.2 meg to my program. Now, I cannot upload it to the site because it is now to big. The site only allows 6.0 meg and my program is 7.312 megs.
I did a real nice job on it too. I also added ...
(If MsgBox("Are you sure you want to delete these files?", MsgBoxStyle.YesNo, "Ready to Delete Files?") = vbYes Then...) this code you that you left and it works a lot better. The Environment.GetFolderPath(...) is also a lot faster.
 
Once again, THNX for the Lesson.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralRe: Hardcoded System PathmemberTapsnapper30 Jan '09 - 6:16 
No problem. If you want to email me your email address I can send you an eBook on VB.net programming which may be useful to you. You can always email me a copy of your new source code as well; I'd be interested in seeing how you've implemented the changes. My email address is paulwilcox@ymail.com. This is my public email address.
GeneralRe: Hardcoded System Pathmemberrspercy5830 Jan '09 - 7:06 
THNX. I'll zip it up and send you the code.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralRe: Hardcoded System PathmemberShane Story6 Feb '09 - 4:15 
something must be wrong.. An with only buttons for an interface should never be 6MB.
 
I have some very sophisticated apps full of graphics that are only 2MB. Are there other screens besides the one shown for a screenshot or other reasons it is so big?
 
Shane

GeneralRe: Hardcoded System Pathmemberrspercy586 Feb '09 - 4:23 
My other app is 9.23 meg in size because of the Environment Class. It added 3.3 meg to the app. This app how ever is only 250+ kb's
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralNice conceptmemberRick Hansen28 Jan '09 - 4:44 
I gave you a 5 for the concept. Vista can be a pain in the ass when it comes to finding things like utilities in the user interface. There are a whole lot of different approaches one can take in a "launcher" application like this. But guys who see a problem and think of a concept solution get a 5 from me (even if the UI is ugly for now Smile | :)
GeneralRe: Nice conceptmemberrspercy5828 Jan '09 - 7:29 
THNX for the globes. I am currently designing a new UI with 100+ commands or about 90% of the control panel. All commands are being put into categories using the WinExec() Function. I found this to be more stable.
Once again THNX.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralMy vote of 1memberCPAV27 Jan '09 - 7:56 
Baaaaad interface, totaly ugly
GeneralRe: My vote of 1memberrspercy5827 Jan '09 - 9:34 
It is for educational purposes, not for looks.
 
rspercy
1 + 1 = 186,440....Depending on the species.

General5/5 Useful Stuffmemberprasad0226 Jan '09 - 20:37 
5/5 Useful Stuff Smile | :)
 
Thanks and Regards,
prasad

GeneralRe: 5/5 Useful Stuffmemberrspercy5827 Jan '09 - 1:42 
THNX for the globes. I am currently redoing this project. I am putting everything into categories. I am adding dual monitor commands depending on what type video card you have, and alot more. Once again, THNX.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralIdeamemberJon25 Jan '09 - 23:30 
It would be more useful to me if the commands were grouped, e.g. Control panel, Internet, security, network, general. Also being able to remove unwanted commands would then give a list of easier to find useful commands. At the moment there's just a bit too many to find the ones I'd like to use.
 
Jon
GeneralRe: Ideamemberrspercy5826 Jan '09 - 0:49 
That is an excellent Idea. I will do this and let you know when it's done.
THNX. All comments are appreciated, Ideas especially.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralRe: Ideamembersupercat926 Jan '09 - 12:02 
This application gives me an idea for something similar in concept, but which might be more useful and versatile: a tray icon with easily-configurable pop-up menu that could hold any desired applications, preferably with support for nesting items. I wouldn't want to steal your thunder by producing such a thing without acknowledging where the idea of building such a mini-utility came from. What do you think?
 
BTW, while some people might think it old and clunky, I'm a fan of text-file-based configuration. It makes it easy to apply systemic changes to a collection of options, and it's generally easy to implement.
GeneralRe: Ideamemberrspercy5827 Jan '09 - 1:47 
Thats a fantastic Idea. I am currently giving the program a new face lift. Adding alot more commands, dual monitor commands, you get the idea and along with having it sit in the sys-tray.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralVery Usefulmembersam.hill25 Jan '09 - 9:27 
Thanks!
GeneralRe: Very Usefulmemberrspercy5825 Jan '09 - 9:33 
THNX Sam. I redid the program. PLZ redownload it.
 
rspercy
1 + 1 = 186,440....Depending on the species.

GeneralRe: Very Usefulmembersam.hill25 Jan '09 - 12:45 
OK, will do.
A few of the calls did not work on my system (Vista64), but I have not yet investigated to determine why.
Others I was not familiar with, so your program has good educational value in addition to the utility!
GeneralRe: Very Usefulmemberrspercy5825 Jan '09 - 23:19 
I fixed the Internet Options click event. There was some typo's that had to be taken care of. And there was some message boxes added. And i disabled the Open With Dialog button as it had no use in that type of program. All you get is a message box when you click on it. Once again, THNX Sam.
 
rspercy
1 + 1 = 186,440....Depending on the species.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 25 Jan 2009
Article Copyright 2009 by rspercy65
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid