Click here to Skip to main content
15,887,376 members
Articles / Desktop Programming / Win32

47 Useful Windows Vista Command-Line Utilities

Rate me:
Please Sign up or sign in to vote.
4.31/5 (25 votes)
25 Jan 2009CPOL2 min read 87K   735   64   37
47 of the most used Vista apps are just 1 click away. NOTE: Vista users only.
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:

VB.NET
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)


Written By
Retired
United States United States
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)

Comments and Discussions

 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey24-Feb-12 2:05
professionalManoj Kumar Choubey24-Feb-12 2:05 
GeneralNo action at 'Display settings' Pin
dherrmann27-Mar-09 12:02
dherrmann27-Mar-09 12:02 
GeneralRe: No action at 'Display settings' Pin
rspercy6527-Mar-09 14:03
rspercy6527-Mar-09 14:03 
GeneralRe: No action at 'Display settings' Pin
dherrmann27-Mar-09 22:15
dherrmann27-Mar-09 22:15 
GeneralRe: No action at 'Display settings' Pin
rspercy6527-Mar-09 22:55
rspercy6527-Mar-09 22:55 
GeneralNice Pin
J Sullivan16-Mar-09 11:49
J Sullivan16-Mar-09 11:49 
GeneralRe: Nice Pin
rspercy6516-Mar-09 13:55
rspercy6516-Mar-09 13:55 
GeneralGood Article -some advice Pin
Tino123-Feb-09 20:30
Tino123-Feb-09 20:30 
GeneralRe: Good Article -some advice Pin
rspercy6524-Feb-09 0:36
rspercy6524-Feb-09 0:36 
GeneralVery Educantional Pin
pennyjp22-Feb-09 0:56
pennyjp22-Feb-09 0:56 
Generalgood article Pin
Donsw19-Feb-09 14:40
Donsw19-Feb-09 14:40 
GeneralNew Control panel app is complete. Pin
rspercy6528-Jan-09 12:17
rspercy6528-Jan-09 12:17 
GeneralHardcoded System Path Pin
Euhemerus28-Jan-09 7:10
Euhemerus28-Jan-09 7:10 
GeneralRe: Hardcoded System Path Pin
rspercy6528-Jan-09 7:33
rspercy6528-Jan-09 7:33 
GeneralRe: Hardcoded System Path Pin
TobiasP29-Jan-09 9:43
TobiasP29-Jan-09 9:43 
GeneralRe: Hardcoded System Path Pin
Euhemerus29-Jan-09 11:05
Euhemerus29-Jan-09 11:05 
GeneralRe: Hardcoded System Path Pin
rspercy6529-Jan-09 12:51
rspercy6529-Jan-09 12:51 
GeneralRe: Hardcoded System Path Pin
Euhemerus30-Jan-09 4:04
Euhemerus30-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<br />
....<br />
....<br />
....<br />
<br />
Private Sub btnDeleteTIF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteTIF.Click<br />
ans = MsgBox("Are you sure you want to delete these files?", MsgBoxStyle.YesNo, "Ready to Delete Files?"))<br />
        If ans = vbYes Then<br />
            fileArgs = "InetCpl.cpl,ClearMyTracksByProcess 8"<br />
            cmdProcess.StartInfo.Arguments = fileArgs<br />
            cmdProcess.StartInfo.WorkingDirectory = path<br />
            cmdProcess.StartInfo.FileName = "RunDll32.exe"<br />
            cmdProcess.Start()<br />
            cmdProcess.WaitForExit()<br />
<br />
            Me.Show()<br />
        Else<br />
            MessageBox.Show("Process Cancelled!")<br />
            Exit Sub<br />
        End If<br />
 End Sub<br />
<br />


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<br />
<br />
        If MsgBox("Are you sure you want to delete these files?", MsgBoxStyle.YesNo, "Ready to Delete Files?") = vbYes Then<br />
            fileArgs = "InetCpl.cpl,ClearMyTracksByProcess 8"<br />
            cmdProcess.StartInfo.Arguments = fileArgs<br />
            cmdProcess.StartInfo.WorkingDirectory = path<br />
            cmdProcess.StartInfo.FileName = "RunDll32.exe"<br />
            cmdProcess.Start()<br />
            cmdProcess.WaitForExit()<br />
<br />
            Me.Show()<br />
        Else<br />
            MessageBox.Show("Process Cancelled!")<br />
            Exit Sub<br />
        End If<br />
    End Sub<br />


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 Path Pin
rspercy6530-Jan-09 5:01
rspercy6530-Jan-09 5:01 
GeneralRe: Hardcoded System Path Pin
Euhemerus30-Jan-09 6:16
Euhemerus30-Jan-09 6:16 
GeneralRe: Hardcoded System Path Pin
rspercy6530-Jan-09 7:06
rspercy6530-Jan-09 7:06 
GeneralRe: Hardcoded System Path Pin
Shane Story6-Feb-09 4:15
Shane Story6-Feb-09 4:15 
GeneralRe: Hardcoded System Path Pin
rspercy656-Feb-09 4:23
rspercy656-Feb-09 4:23 
GeneralNice concept Pin
Rick Hansen28-Jan-09 4:44
Rick Hansen28-Jan-09 4:44 
GeneralRe: Nice concept Pin
rspercy6528-Jan-09 7:29
rspercy6528-Jan-09 7:29 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.