{"id":546,"date":"2015-08-19T06:44:35","date_gmt":"2015-08-19T03:44:35","guid":{"rendered":"https:\/\/furkansandal.com\/python-ile-regedit-islemi\/"},"modified":"2015-08-19T06:44:35","modified_gmt":"2015-08-19T03:44:35","slug":"python-ile-regedit-islemi","status":"publish","type":"post","link":"https:\/\/furkansandal.com\/python-ile-regedit-islemi\/","title":{"rendered":"Python ile Regedit \u0130\u015flemi"},"content":{"rendered":"
\n<\/p>\n
\n<\/div>\n

Merhaba arkada\u015flar. Yakla\u015f\u0131k 2 ayd\u0131r blo\u011fa makale ekleyemiyorum i\u015flerimin yo\u011funlu\u011fu nedeniyle..<\/p>\n

Bug\u00fcnk\u00fc konumuz Python dili ile yapm\u0131\u015f oldu\u011fumuz program\u0131m\u0131z\u0131 Windows \u0130\u015fletim Sistemi ba\u015flang\u0131c\u0131na(startup) nas\u0131l ekleriz? Bu konuyu i\u015fleyece\u011fiz.<\/p>\n

Bu i\u015flemi Windows sistemler \u00fczerinde yapaca\u011f\u0131m\u0131z i\u00e7in yeni bir regedit kayd\u0131 olu\u015fturmam\u0131z gerekiyor.<\/p>\n

Pythonda yeni regedit kayd\u0131 olu\u015fturmam\u0131z\u0131 sa\u011flayan kod \u015fu \u015fekildedir:<\/p>\n

\nkey=_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,”Software\\Microsoft\\Windows\\CurrentVersion\\Run”,
0, _winreg.KEY_ALL_ACCESS)<\/b><\/p><\/blockquote>\n

\nEvet bu komutu k\u0131saca a\u00e7\u0131klamak gerekirse;
\n_winreg.OpenKey ile HKEY_CURRENT_USER alt\u0131nda yeni bir regedit kayd\u0131 a\u00e7t\u0131k ve parantezler i\u00e7inde bu kayd\u0131n regeditteki konumunu belirttik.<\/p>\n

Daha sonrada a\u015fa\u011f\u0131daki kodu yazmam\u0131z gerekiyor;<\/p>\n

\n_winreg.SetValueEx(key, “iso”, 0, _winreg.REG_SZ, “C:\\python27python.exe “+ os.getcwdu() + “\\kopyala.py”)
key.Close()<\/b><\/p><\/blockquote>\n

Yukardaki kod ise; olu\u015fturaca\u011f\u0131m\u0131z regedit kayd\u0131n\u0131n de\u011ferlerini(value) tan\u0131mlad\u0131k (kay\u0131t ismi=iso<\/u>).
\nSonra olarak da key.Close() ile regedit kayd\u0131m\u0131z\u0131 kapatt\u0131k.<\/p>\n

NOT:<\/u> E\u011fer Python program\u0131m\u0131zda b\u00f6yle bir i\u015flem yapacaksak _winreg mod\u00fcl\u00fcn\u00fc import etmemiz gereklidir.<\/p>\n

\u015eimdi k\u00fc\u00e7\u00fck bir uygulamayla bu konuyu peki\u015ftirelim.<\/p>\n

\u00d6rnek Python program\u0131m\u0131z\u0131n g\u00f6revi \u015fudur:
C:python27test.txt konumundaki test.txt dosyas\u0131n\u0131 C:\\Users\\\u0130smail\\Desktop\\ konumuna yani masa\u00fcst\u00fcne iso.txt olarak kopyalamak. Kopyalama i\u015flemi ms-dos komutlar\u0131yla yap\u0131lmaktad\u0131r(copy komutu). Ve \u0130\u015fletim sistemleriyle ilgili i\u015flemlerde Python kodumuza OS mod\u00fcl\u00fcn\u00fc import etmeyi unutmamam\u0131z gerekiyor.<\/p>\n

Son olarak bu programdaki en b\u00fcy\u00fck fark \u015fudur ki bu i\u015flem bilgisayar her a\u00e7\u0131ld\u0131\u011f\u0131nda otomatikman ger\u00e7ekle\u015fmesidir.<\/p>\n

\u00d6rnek program kodlar\u0131:<\/p>\n

\n# -*- coding: cp1254 -*-
#Coded by iSo
#Website: www.ismailsaygili.com.tr && www.secwis.com
#Copyright 2013 \u00a9<\/span><\/p><\/blockquote>\n

\nimport<\/span> os,_winreg\u00a0<\/p><\/blockquote>\n

\nos.system(“copy C:\\python27\\test.txt C:\\Users\\\u0130smail\\Desktop\\iso.txt”<\/span>)\u00a0<\/p><\/blockquote>\n

\nkey=_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,“Software\\Microsoft\\Windows\\CurrentVersion\\Run”<\/span>,
0, _winreg.KEY_ALL_ACCESS)\u00a0<\/p><\/blockquote>\n

\n_winreg.SetValueEx(key, “iso”<\/span>, 0, _winreg.REG_SZ, “C:\\python27python.exe “<\/span>+ os.getcwdu() + “\\kopyala.py”<\/span>)\u00a0<\/p><\/blockquote>\n

\nkey.Close()<\/p><\/blockquote>\n

\nVeya kodlar\u0131 indirmek i\u00e7in t\u0131klay\u0131n\u00a0veya GitHub<\/b><\/p>\n

Program \u00e7al\u0131\u015ft\u0131ktan sonra:<\/p>\n

\n<\/div>\n

\u0130yi \u00e7al\u0131\u015fmalar..\n<\/p>\n<\/div>\n

\nFurkan SANDAL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

Merhaba arkada\u015flar. Yakla\u015f\u0131k 2 ayd\u0131r blo\u011fa makale ekleyemiyorum i\u015flerimin yo\u011funlu\u011fu nedeniyle.. Bug\u00fcnk\u00fc konumuz Python dili ile yapm\u0131\u015f oldu\u011fumuz program\u0131m\u0131z\u0131 Windows…<\/p>\n","protected":false},"author":1,"featured_media":483,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":""},"categories":[6,1,9,10,7,4],"tags":[78,76,88,89,26,83,81,79,82,77,80,84,85,87,86],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/furkansandal.com\/wp-content\/uploads\/2015\/08\/linux-ubuntu-wallpapers-31.jpeg?fit=1600%2C1200&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6BM7I-8O","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/posts\/546"}],"collection":[{"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/comments?post=546"}],"version-history":[{"count":0,"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/posts\/546\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/media\/483"}],"wp:attachment":[{"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/media?parent=546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/categories?post=546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/furkansandal.com\/wp-json\/wp\/v2\/tags?post=546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}