Hack Forums
[Python] making a python script run cmd command on windows - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] making a python script run cmd command on windows (/showthread.php?tid=5018005)



making a python script run cmd command on windows - jackharper - Oct 11, 2015

Hello Friends
I am learning python language for 2 weeks now
i was curious that can we write a script wchich can run a cmd command on windows
like we defince a fucntion and usualy say print
instead of print how can we make it run cmd command.
thanks for help


* - SIM-1866423 - Oct 11, 2015

PHP Code

<?php 
import os
os
.system("dir") etc.. 



* - jackharper - Oct 11, 2015

(Oct 11, 2015 04:01 AM)b3mb4m Wrote:  
PHP Code

<?php 
import os
os
.system("dir") etc.. 

diretory to what..?
lets just say we want to shutdown pc through python script with cmd command
what will that be..?


* - Mr. Robot - Oct 11, 2015

(Oct 11, 2015 04:51 AM)jackharper Wrote:  diretory to what..?
lets just say we want to shutdown pc through python script with cmd command
what will that be..?

Cmd directory? It's in your system32 folder


* - SIM-1866423 - Oct 11, 2015

Than, shutdown of course .. try it before u ask anything ..

PHP Code

<?php 
os
.system("shutdown now -h") 



* - jackharper - Oct 11, 2015

(Oct 11, 2015 04:58 AM)b3mb4m Wrote:  Than, shutdown of course .. try it before u ask anything ..

PHP Code

<?php 
os
.system("shutdown now -h") 

ok thanks... i did everything i could have...
cheers