#๐Ÿ”’ Why this exe doesnt works?

90 messages ยท Page 1 of 1 (latest)

lime aspen
#
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)
celest deltaBOT
#

@lime aspen

Python help channel opened

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.

lime aspen
#

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

versed stone
#

!rule 5

celest deltaBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

lime aspen
#

thats totally legal

#

thats for me

#

when my wifi stop working it resets it

versed stone
lime aspen
#

better?

#

the site doesnt matters

versed stone
#

Nope. Twitter also requires an API

lime aspen
#

so what site i should use? lol

versed stone
#

Probably one that doesn't need an API to use it

lime aspen
#
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

left rock
#

I dont think its against google's tos to do this

#

i think you're just fine with google

lime aspen
#

why the exe doesnt works?

left rock
#

try adding input() somewhere in there

lime aspen
#

the cmd open and close

modern hare
lime aspen
#

sorry for the music

#

I did not notice

modern hare
#

xD

lime aspen
modern hare
#

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

modern hare
#

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

lime aspen
#

Found it

north lion
#

you don't need to include netsh with pyinstaller thoguh

lime aspen
#

so what i have to do? ๐Ÿ˜…

north lion
#

run the exe via cmd

#

so you can see the error

lime aspen
#

the window open then close, nothing appears in cmd

north lion
#

don't use start

#

just main.exe

lime aspen
#

the program start then it closes

#

again

modern hare
#

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()
north lion
#

works for me too.

modern hare
lime aspen
#

but it just works in the pycharm

#

not in the exe

north lion
#

it works with the exe for me as well.

lime aspen
#

OK

#

WORKD

#

lol

#

why it worked?

north lion
#

no clue what you did so

lime aspen
#
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

lime aspen
#

i tried again and didnt work

north lion
#

your code there has it uncommented

modern hare
#

i just used 'netrc help'

lime aspen
north lion
#

again, i used your code

lime aspen
#

to execute the netsh operation i have to execute as admin

modern hare
lime aspen
#

ok

#

i found a way

#

it workd

#

so i use it instead of pyuac

modern hare
#

nice

unborn sigil
lime aspen
#

Thx u all

lime aspen
#

and it is easier

unborn sigil
lime aspen
#

!close

celest deltaBOT
#
Python help channel closed

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.