problem in Shell Function

Joined
Jun 6, 2008
Messages
9
Programming Experience
Beginner
Hello Guys,

I'm trying to write a very simple Windows service in VB.NET that call the regedit.exe using the shell function in vb.net. I have done shell commands in other services that I've written and never had an issue. For some reason unknown to me, shell does not work in this particular situation. Can anyone help me and explain why it doesnt work?:mad::(

I already try these following commands,

Shell("C:\WinNT\regedit.exe", AppWinStyle.NormalFocus)
**********************
Shell(My.Settings.AppToRun.ToString, AppWinStyle.NormalFocus) '--> My.Settings.AppToRun =C:\Winnt\regedit.exe

I also try this syntax and call the sub but it didnt work.

VB.NET:
Public Sub RunReg()

        Dim pCommand As New System.Diagnostics.Process

        Try
            With pCommand.StartInfo
                .WorkingDirectory = "C:\Winnt\"
                .FileName = "Regedit.exe"
                .WindowStyle = ProcessWindowStyle.Normal
            End With
            pCommand.Start()
            pCommand.WaitForExit()

        Catch ex As Exception
            WriteLog(ex.Message)
        End Try
        pCommand.Dispose()
        pCommand = Nothing

    End Sub

Im sure that my syntax is correct but i cant explain why it wont works, I already write this kind of program but i dont know why it doesnt work in this situation, Can anyone explain this? thanks in advance.
 
Is the WorkingDirectory correct? Usually windows is installed to 'C:\Windows' not 'C:\Winnt' (This is just a suggestion, if you're using windows 2000, then yes 'C:\Winnt' is usually the default install folder)
 
yeah. my working directory is correct. im in windows 2000 operating system. Is there problem with my syntax? Actually I try it in a windows application and it works, but when i insert it in a windows service i cant catch the errors why it wont works.
 
Back
Top