Jump to content
Sign in to follow this  
TecGuy

Modifying a EnvSet and running $command = Run

Recommended Posts

TecGuy

Hi everyone

Wow this is great. I found the site Friday a week ago and have been impressed with the short learning curve.

(I only use to write bat files):D

I am running into an issue that i just cannot find an answer for.

I am running the following command:

EnvSet ( "Text" )

$command = Run(@ComSpec & " /c " & "Run.exe","",@SW_HIDE,3)

$read = ""

Do

If StdoutRead($command,1,True) Then

$read = StdoutRead($command)

If @error Then ExitLoop

_FileWriteLog( "C:\Test.csv",$read)

If Not StringInStr($read,"End") Then $read = "" ; EndIf

Until $read <> ""

StdinWrite($command,"x")

I need it to do something like the following:

$First = "c:\Test.csv"

$First1 = "joe"

$Next = "c:\Test1.csv"

$Next1 = "joe1"

$Last = "Finish"

EnvSet ( "Text" & $First & "Text" $First1 & "Text")

$command = Run(@ComSpec & " /c " & "Run.exe","",@SW_HIDE,3)

$read = ""

Do

If StdoutRead($command,1,True) Then

$read = StdoutRead($command)

If @error Then ExitLoop

_FileWriteLog( "C:\Test.csv",$read)

If Not StringInStr($read,"End") Then $read = "" ; EndIf

Until $read <> ""

StdinWrite($command,"x")

1.I need it to insert the EnvSet line with varible set (something like the example above)

2.repeat the $command until it sees $Last = "Finish" Or runs out of varibles in that string

3. If possible i would like the script to set the initial EnvSet from the first varible set

4. Also a long shot have each $command run at the same time

5. Rename to $command = Run line to then $command1 $command2 etc on each run

6. Also Whith the rename i will need to pull the next $command number into my If StdoutRead($command,1,True) statement to run it properly (I think)

I know i ask a lot of this forum and would appreiate any help. Thank you in advance.

Share this post


Link to post
Share on other sites
wolf9228

Hi everyone

Wow this is great. I found the site Friday a week ago and have been impressed with the short learning curve.

(I only use to write bat files):D

I am running into an issue that i just cannot find an answer for.

I am running the following command:

EnvSet ( "Text" )

$command = Run(@ComSpec & " /c " & "Run.exe","",@SW_HIDE,3)

$read = ""

Do

If StdoutRead($command,1,True) Then

$read = StdoutRead($command)

If @error Then ExitLoop

_FileWriteLog( "C:\Test.csv",$read)

If Not StringInStr($read,"End") Then $read = "" ; EndIf

Until $read <> ""

StdinWrite($command,"x")

I need it to do something like the following:

$First = "c:\Test.csv"

$First1 = "joe"

$Next = "c:\Test1.csv"

$Next1 = "joe1"

$Last = "Finish"

EnvSet ( "Text" & $First & "Text" $First1 & "Text")

$command = Run(@ComSpec & " /c " & "Run.exe","",@SW_HIDE,3)

$read = ""

Do

If StdoutRead($command,1,True) Then

$read = StdoutRead($command)

If @error Then ExitLoop

_FileWriteLog( "C:\Test.csv",$read)

If Not StringInStr($read,"End") Then $read = "" ; EndIf

Until $read <> ""

StdinWrite($command,"x")

1.I need it to insert the EnvSet line with varible set (something like the example above)

2.repeat the $command until it sees $Last = "Finish" Or runs out of varibles in that string

3. If possible i would like the script to set the initial EnvSet from the first varible set

4. Also a long shot have each $command run at the same time

5. Rename to $command = Run line to then $command1 $command2 etc on each run

6. Also Whith the rename i will need to pull the next $command number into my If StdoutRead($command,1,True) statement to run it properly (I think)

I know i ask a lot of this forum and would appreiate any help. Thank you in advance.

;Example EnvSet And EnvGet

EnvSet("PATH", "C:\WINDOWS")
$var = EnvGet("PATH")
MsgBox(4096, "Path variable is:", $var)

;Example StdoutRead

#include <Constants.au3>
$file = FileOpen("command.cmd", 1)
FileWrite($file, "cmd.exe /? " & @CRLF & "Pause")
FileClose($file)
Run("command.cmd", @ScriptDir, @SW_SHOW)
Local $foo = Run("command.cmd", @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line

While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites
TecGuy

Thanks for your reply. I am confused by your answer. I dont think it is what i am looking for.

I'm going to try do a better job of asking my question.

I would like to take the following EnvSet Statement and Dynamically Rename Portions using some type of $var so i can modify them easily

Is this possible?

if not what would be my best solution?

$file = "Test_" ;log file name
$ext = ".csv"
$file1 = "Test_1" ;Next log file name
$ext1 = ".txt"
$file2 = "Test_2" ;Next log file name
$ext2 = ".log"
EnvSet ( "setcmd" , "C:\Program.exe -logfile=c:\Log\"&$file&$ext)

Next i would like run the command below.

$command = Run(@ComSpec & " /c " & "C:\Program.exe","",@SW_HIDE,3)

While the $command above is running i am using my pause loop to get a log and pause the script until $command is finished

$read = "" 
Do
    If StdoutRead($command,1,True) Then
        $read = StdoutRead($command)
        If @error Then ExitLoop
        _FileWriteLog( "c:\Log\running_log.csv",$read)
        If Not StringInStr($read,"closing program") Then $read = ""
    EndIf
Until $read <> ""
StdinWrite($command,"x")

my dream would be to have this repeat the process and set the EnvSet line with the next set of vars &$file1&$ext1,then &$file2&$ext2,and keep repeating until all of the varibles have been used.

I hope I did a better job this time.

Thanks again,

TecGuy

Edited by TecGuy

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.