{"id":368,"date":"2008-05-23T10:01:17","date_gmt":"2008-05-23T10:01:17","guid":{"rendered":"http:\/\/6teen.ru\/?p=107"},"modified":"2008-05-23T10:01:17","modified_gmt":"2008-05-23T10:01:17","slug":"5597","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=368","title":{"rendered":"\u0415\u0441\u0442\u044c \u0432 \u0432\u0438\u043d\u0434\u0435 \u0425\u0420 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 runas"},"content":{"rendered":"<p>\u0415\u0441\u0442\u044c \u0432 \u0432\u0438\u043d\u0434\u0435 \u0425\u0420 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 runas<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u0415\u0441\u0442\u044c \u0432 \u0432\u0438\u043d\u0434\u0435 \u0425\u0420 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 runas.\n\n\u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u043e\u0434 \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.\n\u0418\u0433\u043e\u0440\u044c \u0428\u0435\u0432\u0447\u0435\u043d\u043a\u043e c (30.10.04 17:10) [2]\ncreateprocesswithlogonw\n\nprocedure tfmain.mycreateprocess;\nconst\nusername : widestring = 'testuser';\npassword : widestring = 'testuser';\nconstcommandline : string = 'cmd.exe';\ntitle : widestring = 'test process';\ndomain : widestring = 'workgroup';\nvar\nmystartupinfo : startupinfo;\nprocessinfo : process_information;\ncommandline : array[0..512] of widechar;\nbegin\nfillchar(mystartupinfo, sizeof(mystartupinfo), 0);\nmystartupinfo.cb := sizeof(mystartupinfo);\nstringtowidechar(constcommandline, commandline,\nsizeof(commandline) div sizeof(widechar));\nmystartupinfo.lptitle := pwidechar(title);\nif not createprocesswithlogonw (pwidechar(username), pwidechar(domain),\npwidechar(password), logon_with_profile, nil,\ncommandline, 0, nil, nil, @mystartupinfo, @processinfo) then\nraiselastwin32error()\nelse begin\nclosehandle(processinfo.hprocess);\nclosehandle(processinfo.hthread);\nend;\n\nunit hsadvapi;\n\ninterface\nuses\nwindows;\n\nfunction createprocesswithlogonw (const lpusername : pwidechar;\nconst lpdomain : pwidechar; const lppassword : pwidechar;\ndwlogonflags : dword; const lpapplicationname : pwidechar;\nlpcommandline : pwidechar; dwcreationflags : dword;\nlpenvironment : pointer; const lpcurrentdirectory : pwidechar;\nlpstartupinfo : pstartupinfo;\nlpprocessinfo : pprocessinformation) : boolean; stdcall;\n\nconst\nlogon_with_profile = $00000001;\nlogon_netcredentials_only = $00000002;\nlogon_zero_password_buffer = $80000000;\n\nimplementation\nuses\nsysutils;\n\n{ advapi32.dll functions }\ntype\ntcreateprocesswithlogonw =\nfunction (const lpusername : pwidechar;\nconst lpdomain : pwidechar; const lppassword : pwidechar;\ndwlogonflags : dword; const lpapplicationname : pwidechar;\nlpcommandline : pwidechar; dwcreationflags : dword;\nlpenvironment : pointer; const lpcurrentdirectory : pwidechar;\nlpstartupinfo : pstartupinfo;\nlpprocessinfo : pprocessinformation) : boolean; stdcall;\n\nconst\ndllname = 'advapi32.dll';\n\nvar\ndllhandle : thandle;\n_createprocesswithlogonw : tcreateprocesswithlogonw;\n\nfunction initlib : boolean;\nbegin\nif dllhandle = 0 then\nif win32platform = ver_platform_win32_nt then begin\ndllhandle := loadlibrary(dllname);\nif dllhandle <> 0 then begin\n@_createprocesswithlogonw := getprocaddress(dllhandle,\n'createprocesswithlogonw');\nend;\nresult := (dllhandle <> 0);\nend;\n\nfunction notimplementedbool : boolean;\nbegin\nsetlasterror (error_call_not_implemented);\nresult := false;\nend;\n\nfunction createprocesswithlogonw (const lpusername : pwidechar;\nconst lpdomain : pwidechar; const lppassword : pwidechar;\ndwlogonflags : dword; const lpapplicationname : pwidechar;\nlpcommandline : pwidechar; dwcreationflags : dword;\nlpenvironment : pointer; const lpcurrentdirectory : pwidechar;\nlpstartupinfo : pstartupinfo;\nlpprocessinfo : pprocessinformation) : boolean; stdcall;\nbegin\nif initlib and assigned(_createprocesswithlogonw) then\nresult := _createprocesswithlogonw(lpusername, lpdomain, lppassword,\ndwlogonflags, lpapplicationname, lpcommandline, dwcreationflags,\nlpenvironment, lpcurrentdirectory, lpstartupinfo, lpprocessinfo)\nelse\nresult := notimplementedbool;\nend;\n\ninitialization\nfinalization\nif dllhandle <> 0 then\nfreelibrary(dllhandle);\nend.\n\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a:\nhttp:\/\/delphimaster.ru\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0415\u0441\u0442\u044c \u0432 \u0432\u0438\u043d\u0434\u0435 \u0425\u0420 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 runas<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[448,454],"tags":[560,637,805],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/368"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/368\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}