Sign in to follow this  
Followers 0
neo van matix

Run *.bat - Doesnt Work :/

15 posts in this topic

Hello,

i've written a little script, which copies some Win2k Updates from a Server to a local folder.

Then, it should run the install.bat, which install the updates.

But, if i run the script, it copies the complete Folder - the install.bat appears for half a second - and then the folder will be deleted.

If i run the install.bat via doubleclick in Windows, it works fine :/

DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates")

Run("c:\Win2k_Updates\install.bat")

ProcessWaitClose("install.bat")
sleep(5000)
DirRemove("c:\Win2k_Updates", 1)

Attention! English noob ^^

Share this post


Link to post
Share on other sites



Try:

Run("run c:\Win2k_Updates\install.bat")

If that does not work, this data may help:

It's default opener is {5e941d80-bf96-11cd-b579-08002b30bfeb}

This can be seen by the registry key:

HKEY_CLASSES_ROOT\.bat\PersistentHandler

#)

Share this post


Link to post
Share on other sites

Hello,

i've written a little script, which copies some Win2k Updates from a Server to a local folder.

Then, it should run the install.bat, which install the updates.

But, if i run the script, it copies the complete Folder - the install.bat appears for half a second - and then the folder will be deleted.

If i run the install.bat via doubleclick in Windows, it works fine :/

DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates")

Run("c:\Win2k_Updates\install.bat")

ProcessWaitClose("install.bat")
sleep(5000)
DirRemove("c:\Win2k_Updates", 1)
Try it like this:

DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates")
RunWait(@ComSpec & ' /k c:\Win2k_Updates\install.bat', 'c:\Win2k_Updates\install.bat')
MsgBox(64, "Debug", "Install.bat complete, check results...")
DirRemove("c:\Win2k_Updates", 1)

That way you can see if it is working the way you want. :think:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Doesnt work :/

run("run ..."):

I get an Error, that the script cant find the install.bat

Psaltyds:

Error, too: "Dirname not valid"

:/

Wtf, why run() cant open a simple *.bat files?


Attention! English noob ^^

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Doesnt work :/

run("run ..."):

I get an Error, that the script cant find the install.bat

Psaltyds:

Error, too: "Dirname not valid"

:/

Wtf, why run() cant open a simple *.bat files?

Of course it can run .bat files. That "Dirname not valid" needs to be chased to ground first... :think:

Like this, for instance:

If Not DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates") Then
    MsgBox(16, "Error!", "DirCopy failed!  What happened to c:\Win2k_Updates\Install.bat?")
    Exit
EndIf

RunWait(@ComSpec & ' /k c:\Win2k_Updates\install.bat', 'c:\Win2k_Updates\install.bat')

MsgBox(64, "Debug", "Install.bat complete, check results...")

DirRemove("c:\Win2k_Updates", 1)

After you find out what happened to your DirCopy(), change the /k back to /c and delete the Debug MsgBox. :-)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Batch files have a quirk to them with regard to how and where they are run... First, are you running your script in the same dir as the .bat file? If so, do this:

DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates")

Run("c:\Win2k_Updates\install.bat", "", @SW_HIDE)

ProcessWaitClose("install.bat")
sleep(5000)
DirRemove("c:\Win2k_Updates", 1)

If however you are running the script from another location, use this:

DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates")

Run("c:\Win2k_Updates\install.bat", "c:\Win2k_Updates", @SW_HIDE)

ProcessWaitClose("install.bat")
sleep(5000)
DirRemove("c:\Win2k_Updates", 1)

Additionally I would just modify your code above to the following: (If script in same Dir)

DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates")

RunWait("c:\Win2k_Updates\install.bat", "", @SW_HIDE)

sleep(5000)
DirRemove("c:\Win2k_Updates", 1)

This will pause execution of the script until the installation is complete, then continue on with "Sleep()" and "DirRemove"

Share this post


Link to post
Share on other sites

Try

DirCopy("\\192.168.1.28\d$\AutoIT-Scripts\Win2k_Updates", "c:\Win2k_Updates")

$prog = FileGetShortName("c:\Win2k_Updates\install.bat")
Run($prog)

ProcessWaitClose("install.bat")
sleep(5000)
DirRemove("c:\Win2k_Updates", 1)


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

b1t5tR3@m,

I love your avitar... :think:

Do you set a different one on GOOD days? :(

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I think the problem in your original script is the assumption in the line ProcessWaitClose("install.bat")

When a batch file is run, cmd.exe is what appears in the Task Manager's process list--not the name of the bat file. As other people have shown, RunWait is the command you are looking for :think:

Would it be possible to get rid of the batch file and use built-in AutoIt commands?

Also, using FileChangeDir sometimes works better:

FileChangeDir("C:\Win2k_Updates")
RunWait("install.bat","",@SW_HIDE)
MsgBox(0,"Debug","Program is done!")
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

@PsaltyDS

That's my "Whilst debugging code...." Avatar; and that IS on a good day.

:think:

Share this post


Link to post
Share on other sites

I've found an easier way ^^.

I created an SFX archiv with WinRar, witch runs after extraction the included install.bat.

The sfx will be opend trough a autoit-script, which waits to close until the install.bat finished.

Its a little bit complicated, and my bad english will not help u to understand, what i want to do *g*. I write a little installscript, which installs 10-20 autom. Installations. After 1 Program was installed, i force a reboot.

As long as the autoit-script is open, nothing happens. 10 Seconds after the autoit-script finished, the script forces a reboot. After boot, the main installer-script starts again... and continues with the next program.

Hm, unimportant... ^^


Attention! English noob ^^

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

ShellExecute("install.bat","","c:Win2k_Updates")

Edited by alaa777

Share this post


Link to post
Share on other sites

#13 ·  Posted

7 years later ... nice exhumation :D

Share this post


Link to post
Share on other sites

#14 ·  Posted

alaa777, as mikell alluded to, please do not resurrect a 7 year old thread just to make a comment. As the OP has not been active in nearly 2 years, it is unlikely that

A: he is still looking to update Windows 2000

B: he will benefit from your advice anyway.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

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