johnnykenshien
Member
- 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?
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.
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.
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?
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.