# Pull information from a ini file from batch file



## solsie (Dec 12, 2008)

I have a batch file that essentially stops my virtual server, copies files, starts virtual server, compresses files and finally removes temp folder.

I would like to have a ini file to store information like:

VMStop Path=cd c:\virtual machines\vmware\vmware server
VMStop Command=call vmware-cmd "c:\virtualmachines\xp\xp.vmx" stop
CopyPath=C:\backups\server1
VMStart PAth=cd c:\virtual machines\vmware\vmware server
VMStart Command= call vmware-cmd "c:\virtualmachines\xp\xp.vmx" start

I was able to put a ini file in place and store set commands in it and pull those out, but not sure how to do teh above. Any help would be appreciated.

S


----------



## -Fabez- (Jul 28, 2008)

You could use a series of find statements, but it would become difficult to maintain and debug, I would recoment using Python instead as you can still use batch commands, but it is a higher level language.


----------



## AKAJohnDoe (Jun 6, 2007)

An alternative to Python is AutoIt


----------



## solsie (Dec 12, 2008)

ok thank you.

S.


----------



## solsie (Dec 12, 2008)

the only thing i see is i will have to rewrite or change several lines for autoit, which i assume i would have to do for python too. 

Oh well, luckily it did not take me too long to do the original script.

thanks.


----------



## -Fabez- (Jul 28, 2008)

Not necessarily  All you need to do is wrap all of the lines from your batch file in the os.system command, which basically means it will be executed as if it had been entered into the command prompt. A simple example is below.


```
import os
os.system ("Your Command Here")
os.system ("pause")
```
It would be easy to make a simple utility to wrap all of the lines in your batch file automatically, meaning you can concentrate on adding the .Ini feature you want


----------

