qadeer37
Well-known member
for example there is a file named abc.exe in c: 
what would be the code for executing this file?
	
		
			
		
		
	
				
			what would be the code for executing this file?
Shell([COLOR="red"]{filename}[/COLOR], [COLOR="green"]{appwinstyle}[/COLOR], [COLOR="blue"]{wait}[/COLOR], [COLOR="purple"]{timeout}[/COLOR])One of the many advantages to using the process class is that you can hang on to the reference to the process when executing it:Ah, yes. Sounds good! More "modern" way.
    Private Function WriteRegistry(ByVal StartWithWindows As Boolean) As Boolean
        Dim Output As Boolean = False
        Dim AppName As String = System.IO.Path.GetFileNameWithoutExtension(Environment.GetCommandLineArgs(0I))
        Dim SubKey As Microsoft.Win32.RegistryKey = Nothing
        Try
            SubKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree)
            If StartWithWindows Then
                'Create
                SubKey.SetValue(AppName, Environment.GetCommandLineArgs(0I))
            Else
                'Delete
                Dim KeyExists As Boolean = False
                For Each strkey As String In SubKey.GetValueNames
                    If strkey = AppName Then KeyExists = True
                Next strkey
                If KeyExists Then SubKey.DeleteValue(AppName)
            End If
            Output = True
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "WriteRegistry")
        Finally
            If SubKey IsNot Nothing Then SubKey.Close()
        End Try
        Return Output
    End FunctionThis must be a misconception. CurrentUser is a base key (system key), Close has no effect on this as system keys are never closed. Close method is also not a cascading call, no other open child keys is closed when you close a key. It is the RegistryKey object returned by OpenSubKey that you must close.JuggaloBrotha said:Finally
My.Computer.Registry.CurrentUser.Close()
Right, I've changed the code in my post.This must be a misconception. CurrentUser is a base key (system key), Close has no effect on this as system keys are never closed. Close method is also not a cascading call, no other open child keys is closed when you close a key. It is the RegistryKey object returned by OpenSubKey that you must close.
