PsExec doubt

Discussion in 'other software & services' started by m00nbl00d, Apr 1, 2012.

Thread Status:
Not open for further replies.
  1. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    Note to Mods/Administrators: This is a doubt I express in "OpenDNS dnscrypt now available for Windows" thread, regarding PsExec. I'm posting it here, because most likely it will get more exposure, and it's not a doubt about DNSCrypt. I hope it's OK.

    So, here it comes...

    There's been a long time since I last used PsExec from Sysinternals. I have the following command:

    "C:\PsExecFolder\PsExec.exe" -d -e -u username -p p4ssw0rd "C:\DNSCryptFolder\DNSCrypt.bat"

    If I open the cmd line and copy & paste it, then DNSCrypt will run as username, but if I run it via a batch file, then it won't run.

    Am I missing some other obvious command, that will allow me to run it using a batch file? :oops: :doubt:

    I actually tried "C:\PsExecFolder\PsExec.exe" -d -e -u username -p p4ssw0rd "cmd" "/c "C:\DNSCryptFolder\DNSCrypt.bat"", but it just opens cmd line window with the name C:\DNSCryptFolder\DNSCrypt.bat. o_O

    I appreciate any help. Thanks. :thumb:


    P.S: By the way, if you're familiar with a PsExec similar tool, who knows open source, that allows to encrypt passwords, and if you know it to be good, I'd like to also know about it. Thanks. :)
     
  2. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,113
    Location:
    NSW, Australia
    m00nbl00d,

    Did you right click the batch file and Run as Administrator?
     
  3. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    No, I have not. I didn't try it, as I believe that will make both PsExec and DNSCrypt tool run as admin as well? They should run with standard user rights. DNSCrypt tool should anyway.

    I'll give it a try, though. Maybe if I use -l, it will make DNSCrypt run as low integrity.

    But, if the issue is administrative privileges, shouldn't copying and pasting the commands to cmd line fail as well? Because, if I do that it does work.
     
  4. rrrh1

    rrrh1 Registered Member

    Joined:
    Sep 10, 2007
    Posts:
    211
    The Command line in batch sometimes eats ":" have you tried putting a pause at the end of the batch to possibly catch the error ?

    rrrh1 (arch1)
     
  5. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    I thought I had, but I didn't. So, I added pause at the end, and I get a message saying that it couldn't open cmd either due to wrong user name or password.

    But, if I manually copy and paste the same command to cmd line, then it will open a cmd window under the desired user account name. The problem is, it will not pass the rest of the command, which is to start the batch file or either the DNSCrypt executable.

    So, it's not due to wrong user name or password. It's just some command that isn't working as it should; or something else is missing. I just can't figure out exactly what is missing. :doubt:
     
  6. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    I forgot to mention that the following command:

    "C:\PsExecFolder\PsExec.exe" -d -e -u username -p p4ssw0rd "C:\DNSCryptFolder\DNSCrypt.bat"

    also results in the same error message, regarding either a wrong user name or password.

    But, if I do copy and paste the above command to the cmd line, then the batch file will initiate under the desired user name account, and on its turn, the batch file will initiate DNSCrypt tool. As it should happen.

    I'm not really understanding why doing the same process using a batch file results in failure. :ouch:

    I really wanted to schedule a task to automate the whole process, instead of doing manually, so I could only have it started when an Internet connection is active. :(
     
  7. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    This is 100% freaking insane.

    I found a way to get the crendentials encrypted using a PowerShell script. I save the credentials encrypted to a file, and then the script loads it again when needed as a secure string as well.

    But, at the image of the batch file with psexec, it still fails to run either the batch file or dnscrypt tool (depending on which one I try to run), and again due to either a wrong user name or password.

    The thing is, both user name and password are right, because I can manually execute it as well.

    WTF? o_O o_O

    Well, I suppose I'm going to register @ some good Powershell scripting forum and maybe there I'll get some help, because I really want to use the PowerShell script, because it will encrypt the credentials. I just need to make it work. :mad:
     
  8. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    OK. I have made some progress.

    After spending hours around the PowerShell script; I actually ended up creating my own. :D Nothing fancy. If one looks for PowerShell help, it's all there... if one gets to spend time reading it. :argh:

    Anyway, I came to realize this may be due to Windows Remote Management service being disabled in my system. In fact, after enabling it, I got a different error message. I checked Event Viewer and there's an error code there. I'm tired for now, so will only be looking for this tomorrow. But, I believe I found the right path to make this work. I hope.

    I think this new error has something to do with firewall rules being disabled for something related to WRM. Let's see.
     
  9. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    Well, I still haven't got PsExec to work. I think that the account's password must have some character that PsExec or either a batch treat with a special meaning.

    Anyway, I got DNSCrypt to automatically run on session logon for the user accounts, under that dedicated and restricted limited user account. :D

    Most likely, the PowerShell script will work now as well. Probably. I'll try it later again. I'll just need to modify it a bit again.
     
  10. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    Some good news. I also managed to get my PowerShell script to work. Now that I look at it, it was freaking obviously what was wrong with it. :oops: :D

    It was quite some journey.

    I still couldn't get PsExec to run the program, using a batch file. Most like due to the password having what's considered a special character. I actually had to escape the character in my PowerShell script.

    I could use PsExec with PowerShell, though. This would allow me to escape the character in question. But, PsExec isn't needed, at all.
     
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.