Search notes:

Examples for Visual Basic for Application accessing the Windows API: CreateProcess

The following example creates a process.
This example needs the VBA declarations of the Windows API which can be found here.
option explicit

sub main() ' {

    dim secAttrPrc as SECURITY_ATTRIBUTES : secAttrPrc.nLength = len(secAttrPrc)
    dim secAttrThr as SECURITY_ATTRIBUTES : secAttrThr.nLength = len(secAttrThr)

    dim startInfo  as STARTUPINFO ' : startInfo.cb = len(startInfo)
    dim procInfo   as PROCESS_INFORMATION

    if CreateProcess (                                         _
         lpApplicationName      :=   vbNullString            , _
         lpCommandLine          :=  "cmd.exe"                , _
         lpProcessAttributes    :=   secAttrPrc              , _
         lpThreadAttributes     :=   secAttrThr              , _
         bInheritHandles        :=   false                   , _
         dwCreationFlags        :=   0                       , _
         lpEnvironment          :=   0                       , _
         lpCurrentDirectory     :=   environ("USERPROFILE")  , _
         lpStartupInfo          :=   startInfo               , _
         lpProcessInformation   :=   procInfo )  then

     else
        MsgBox "Couldn't create process"
     end if

end sub ' }
Github repository WinAPI-4-VBA, path: /examples/CreateProcess.bas

See also

Other examples

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759373919, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/Win-API/examples/CreateProcess(70): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78