Skip to content Skip to sidebar Skip to footer

Script Cannot Read Password

Python script is designed to run with elevated credentials, unfortunately it still prompts me for password when I enter the correct password it doesn't work Here is script1, whi

Solution 1:

Let's talk about your problems one at the time.

1. It still prompts me for password

In the line

os.system('"runas /user:DOMAIN\username "D:/Python27/python.exe script2.py sender-ip=10.10.10.10 < password.txt""')

you're providing the password to script2. runas command still need a password since is trying to run a program as another user.

2. When I enter the correct password it doesn't work

Well ... The code does'n work that's clear. But, you have to be more specific when asking a question. Right now a look to your code and I can see that you're trying to do ping on a remote machine.

Might the remote machine has a firewall? Have you tryed doing ping manually?

Edit: The output.txt file is not created, and running the script don't tell you nothing about error writting the file, obviously your code is hitting one of the sys.exit() lines.

Solution 2:

You can use PsExec https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

You can supply a username and password and executing does not need to be elevated to admin:

psexec [\computer[,computer2[,...] | @file]]\ [-u user [-p psswd] [-n s][-r servicename][-h][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-][-a n,n,...] cmd [arguments]

Use the -e switch to give the same results as Runas /netonly:

-e Does not load the specified account’s profile.

Post a Comment for "Script Cannot Read Password"