Sign in to follow this  
Followers 0
mimo78

difference betwin exe and cmd

6 posts in this topic

I was wondering if someone knew the difference betwin running an exe and running a cmd file?

especially regarding to stdoutread and stderrread functions

reason?

I have some code that execute a psexec (remote execute) that work with exe files but no cmd files:

CODE
#include <GUIConstants.au3>

$serverpath = "\\server\programmer\!deploy"

$program = "testprog2.cmd"

;$program = "testprog.exe"

$username = "Admin"

$password = "fejlkode47"

$host = "\\test-pc"

$install = install($host, $username, $password, $serverpath, $program)

$run = run($install, "",@SW_MAXIMIZE, 2 + 4)

;While 1

; $line = StdoutRead($run)

; If @error Then ExitLoop

; MsgBox(0, "STDOUT read:", $line)

;Wend

While 1

$line = StderrRead($run)

If @error Then ExitLoop

MsgBox(0, "STDERR read:", $line)

Wend

MsgBox(4096, "Status", "Installation Complete")

Func install($host, $username, $password, $serverpath, $program)

$command = "psexec " &$host &" -u " &$username &" -p " &$password &" -i -c " &$serverpath &"\" &$program

return $command

EndFunc

I was wondering if someone could tell me why.

I thought it was the use of unc path I even found a solution for it, but that did not fix it

the cmd file that is executed is the same as the exefile just wrapped in a cmd file with a start /wait command.

this is frustrating me, so I hope for someone to help me


Best Regards Mimo

Share this post


Link to post
Share on other sites



I was wondering if someone knew the difference betwin running an exe and running a cmd file?

especially regarding to stdoutread and stderrread functions

reason?

I have some code that execute a psexec (remote execute) that work with exe files but no cmd files:

CODE
#include <GUIConstants.au3>

$serverpath = "\\server\programmer\!deploy"

$program = "testprog2.cmd"

;$program = "testprog.exe"

$username = "Admin"

$password = "fejlkode47"

$host = "\\test-pc"

$install = install($host, $username, $password, $serverpath, $program)

$run = run($install, "",@SW_MAXIMIZE, 2 + 4)

;While 1

; $line = StdoutRead($run)

; If @error Then ExitLoop

; MsgBox(0, "STDOUT read:", $line)

;Wend

While 1

$line = StderrRead($run)

If @error Then ExitLoop

MsgBox(0, "STDERR read:", $line)

Wend

MsgBox(4096, "Status", "Installation Complete")

Func install($host, $username, $password, $serverpath, $program)

$command = "psexec " &$host &" -u " &$username &" -p " &$password &" -i -c " &$serverpath &"\" &$program

return $command

EndFunc

I was wondering if someone could tell me why.

I thought it was the use of unc path I even found a solution for it, but that did not fix it

the cmd file that is executed is the same as the exefile just wrapped in a cmd file with a start /wait command.

this is frustrating me, so I hope for someone to help me

CMD is the Windows NT command line interface seen in NT/2000/XP. It can be used to emulate dos like features/window. If you are trying to pass this to a cmd window then you may need to use Send otherwise you could write it out in the code to do the same thing.


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

CMD is the Windows NT command line interface seen in NT/2000/XP. It can be used to emulate dos like features/window. If you are trying to pass this to a cmd window then you may need to use Send otherwise you could write it out in the code to do the same thing.

well I am not trying to send this code in my cmd.

I made a simple "show this window for 15 sec and exit" test program(EXE), and it worked.

I was able to remote execute it on an other machine.

I thaught that was it, but when I used one of my cmd installation files it faild.

I have the installation of acrobat reader in a cmd file and it did run on the remote host. But the running window on the "calling host" that startet the remote job never exited.

I then wrapped my "15 sec test" exe into a cmd file with a start /wait \\server\test.exe.

same result. The program ran and exitet on the remote host, but never finishes on the host that initiated the program.

So why does exe work and cmd not?

is it my run line thats wrong?

is it my cmd that could be missing something?

is is the fact that when i call a cmd script on a remote host (or local for that matter) the unc path is ignored and defaults to a windows dir.

I thing I have excluded the last, cus I ran a regedit that disables unc path checking when running cmd scripts (acording to some kb article so it should be ok)

furthermore I used pushd and popd commands witch adds a working dir path to you scrip (again compensating for unc path)

PSexec: (the tool I run)

http://www.microsoft.com/technet/sysintern...ies/psexec.mspx

pushd:

http://www.microsoft.com/resources/documen...d.mspx?mfr=true

Cmd.exe does not support UNC names as the current directory: KB156276

http://support.microsoft.com/kb/156276

I have a lot of cmd scripts (for installation purpos) and I was making this in the intend to run the cmds. (but remotely instead of locally on all my 100+ machines.


Best Regards Mimo

Share this post


Link to post
Share on other sites

update:

I found something interesting that has to do with psexec

when i ran cmd files my autoit application just keeps running the script because the loop never is exited.

The psexecsvc.exe keeps running on the remote host.

When I terminate the process on the remote host, my program exits (as it should, although with an error saying error communicating with psexec service on test-pc.

So:

when I start the remote job by a command prompt there is no problem

When I start the remote job by my scrips something goes wrong and communication is lost.

does this tell anybode something?


Best Regards Mimo

Share this post


Link to post
Share on other sites

when I start the remote job by a command prompt there is no problem

When I start the remote job by my scrips something goes wrong and communication is lost.

does this tell anybode something?

Well I am kind of having this same sort of description when trying to use scripting to run commands in Vista. I don't know whether it is the same base problem though... Would you happen to be talking about a Vista machine here? (If not, ignore this post since I can only reproduce my own problem in Vista.)

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

I found the soulution to my problem:

1 line in cmd file @echo off don't use ANY other line with echo

all my cmds are now stripped down to 3 lines:

@echo off

start wait //server/deploy/program.exe

exit

the problem in my case was the cmd scripts I made and used, not the autoit script

So begin there !


Best Regards Mimo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0