devxlogo

Leverage the improved Shell function

Leverage the improved Shell function

The version of the Shell function included in VB.NET expands on the original version and supports an additional argument that enables you to specify whether to wait until the shelled program terminates, with an optional timeout. This solves an old problem known to many Visual Basic developers without your having to resort to Windows API functions:

' Run Notepad.exe and wait until the user terminates it.Shell("notepad", AppWinStyle.NormalFocus, True)' Run Notepad, then wait max 10 seconds.Dim taskID As LongtaskId = Shell("notepad", AppWinStyle.NormalFocus, True, 10000)If taskID = 0 Then    Console.WriteLine("Notepad has been closed within 10 seconds.")Else    Console.WriteLine("Notepad is still running after 10 seconds.")End If

See also  5 Tips for Working With an Onsite Interpreter
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist