기본 콘텐츠로 건너뛰기

파이썬의 subprocess 모듈을 이용해 ActiveX 메소드 확인하기

import subprocess

if __name__ == '__main__':
 clsid = "2E146AEF-5879-4310-BCC9-8094E3916613"  // CLSID 예
 powershell = subprocess.Popen(["powershell.exe","-command",
 "&{ $clsid = New-Object Guid '%s';$type = [Type]::GetTypeFromCLSID($clsid);$object= [Activator]::CreateInstance($ty    pe);get-member -inputObject $object; }" % clsid]
  ,stdout=subprocess.PIPE,stderr=subprocess.PIPE)  #출력을 처리하기 위해 subprocess로 보냄
result, err = powershell.communicate() # subprocess에 있는 출력을 가져옴

댓글

이 블로그의 인기 게시물

프로그래머스 - 시저 암호

public class Caesar { String caesar ( String s , int n ) { n %= 26 ; String result = "" ; char [] temp = s . toCharArray (); for ( int i = 0 ; i < temp . length ; i ++) { if ( temp [ i ]>= 'a' && temp [ i ]<= 'z' ) temp [ i ] = ( char ) (( temp [ i ]+ n )> 'z' ? ( temp [ i ]+ n - 1 )% 'z' + 'a' : ( temp [ i ]+ n )); else if ( temp [ i ]>= 'A' && temp [ i ]<= 'Z' ) temp [ i ] = ( char ) (( temp [ i ]+ n )> 'Z' ? ( temp [ i ]+ n - 1 )% 'Z' + 'A' : ( temp [ i ]+ n )); result += temp [ i ]; } return result ; } public static void main ( String [] args ) { Caesar c = new Caesar (); System . out . println ( "s는 'a B z', n은 4인 경우: " + c . caesar ( ...