import urllib.request
import os
import pyuac
import time
if not pyuac.isUserAdmin():
pyuac.runAsAdmin()
while True:
def connect(host='http://google.com'):
try:
urllib.request.urlopen(host)
return True
except:
return False
print( "connected" if connect() else "no internet!" )
if not connect():
os.system('netsh interface set interface name = "Wi-fi" disabled')
time.sleep(3)
os.system('netsh interface set interface name = "Wi-fi" enabled')
time.sleep(10)
#๐ Why this exe doesnt works?
90 messages ยท Page 1 of 1 (latest)
@lime aspen
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
Here is the output
the exe file just open the cmd window then close instantly
but when i run it on the pycharm everything works fine
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
why?
thats totally legal
thats for me
when my wifi stop working it resets it
For accessing Google you need to use their API
Nope. Twitter also requires an API
so what site i should use? lol
Probably one that doesn't need an API to use it
import urllib.request
import os
import pyuac
import time
#if not pyuac.isUserAdmin():
# pyuac.runAsAdmin()
while True:
def connect(host='http://fast.com'):
try:
urllib.request.urlopen(host)
return True
except:
return False
print( "connected" if connect() else "no internet!" )
if not connect():
os.system('netsh interface set interface name = "Wi-fi" disabled')
time.sleep(3)
os.system('netsh interface set interface name = "Wi-fi" enabled')
time.sleep(10)```
better? lol
the site doesnt matters
why the exe doesnt works?
try adding input() somewhere in there
does it show an error?
xD
https://stackoverflow.com/questions/66613619/os-system-doesnt-work-after-compiling-with-pyinstaller
might be that you have to add the netsh to extra files
im ultra new in python, thats scares me
you are using os.system('netsh ...')
you are just compiling the .py file and the libraries though.
You also need to add the netsh.exe to the pyinstaller
๐
You can find the location of the netsh.exe by using Get-Command netsh
since you are using auto-py-to-exe, you should add it under the binary section
you don't need to include netsh with pyinstaller thoguh
so what i have to do? ๐
it works for me
import urllib.request
import os
#import pyuac
import time
#if not pyuac.isUserAdmin():
# pyuac.runAsAdmin()
def connect(host='http://fast.com'):
try:
urllib.request.urlopen(host)
return True
except:
return False
def main():
connection_return = connect()
while True:
print( "connected" if connection_return else "no internet!" )
if not connection_return:
os.system('netsh help')
time.sleep(3)
os.system('netsh help')
time.sleep(10)
if __name__ == '__main__':
main()
works for me too.
it works with the exe for me as well.
no clue what you did so
but u removed the essentials commands
import urllib.request
import os
import pyuac
import time
if not pyuac.isUserAdmin():
pyuac.runAsAdmin()
def connect(host='http://fast.com'):
try:
urllib.request.urlopen(host)
return True
except:
return False
def main():
connection_return = connect()
while True:
print( "connected" if connection_return else "no internet!" )
if not connection_return:
os.system('netsh interface set interface name = "Wi-fi" disabled')
time.sleep(3)
os.system('netsh interface set interface name = "Wi-fi" enabled')
time.sleep(10)
if __name__ == '__main__':
main()```
i need everything here
what do you mean we did?
i tried again and didnt work
your code there has it uncommented
i just used 'netrc help'
but the os.system commands
again, i used your code
oh ok, so, the pyuac doesnt works?
to execute the netsh operation i have to execute as admin
im checking
nice
why do you need an .exe by the way...
Thx u all
run when i start the pc
and it is easier
pretty sure u can run a python script too, but anyway, good luck with that.
u can close this thread with !close if you dont need any more help
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.