Sign in to follow this  
Followers 0
spiderkayak

Problems to read variable

6 posts in this topic

:)

it does not execute the line:

RunWait("psexec \\$line -c ops.exe","",@SW_HIDE)

the problem I believe that it is in the variable $line (wich saves a server name), because if I enter the the server name, replacing the $line variable, the command run ok

Here I've leaved my script, please check it!!

*************************************************************

$file = FileOpen("servers.txt", 0)

If $file = -1 Then

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

RunWait("psexec \\$line -c ops.exe","",@SW_HIDE)

Wend

FileClose($file)

*************************************************************

Thank a lot

Share this post


Link to post
Share on other sites

RunWait("psexec \\" & $line & " -c ops.exe","",@SW_HIDE)

<{POST_SNAPBACK}>

Hello Larry thank you for your help I did with <RunWait("psexec \\" & $line & " -c ops.exe","",@SW_HIDE)> and I could run it with the variable. I'm getting the server names from a file text, I could to get the first value (server name), but the 2nd or 3th I can't get it.

:)

Share this post


Link to post
Share on other sites

$files = FileRead("servers.txt",FileGetSize("servers.txt"))
$files = StringSplit(StringStripCR($files),@LF)

For $i = 1 to $files[0]
   If StringStripWS($files[$i],8) <> "" Then _
         RunWait("psexec \\" & $files[$i] & " -c ops.exe","",@SW_HIDE)
Next

<{POST_SNAPBACK}>

:)

Larry, it funtions I mean run remotely, but without the server name. I get a blank variable, I mean the variable can't get the server name from the file text.

I'd like to know how do you think the code could be? is it neccesary put the code I made before.

$file = FileOpen("servers.txt", 0)

If $file = -1 Then

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

RunWait("psexec \\$line -c ops.exe","",@SW_HIDE)

Wend

FileClose($file)

Thank a lot

:D

Share this post


Link to post
Share on other sites

start here...

$files = FileRead("servers.txt",FileGetSize("servers.txt"))
MsgBox(4096,"",$files)

does that show the contents of the file? Each line a new server name?

Lar.

<{POST_SNAPBACK}>

Yes, each line is a new server name:

server1

server2

server3

everything appear in just one windows

Share this post


Link to post
Share on other sites

ok, next this line splits all the servers into an array...

$svrs = StringSplit(StringStripCR($svrs),@LF)

then a for loop using element[0] and adding an if statement for any anomoles.. but here is a msgbox test...

$svrs = FileRead("servers.txt",FileGetSize("servers.txt"))
$svrs = StringSplit(StringStripCR($svrs),@LF)
For $i = 1 to $svrs[0]
   If StringStripWS($svrs[$i],8) <> "" Then _
          MsgBox(4096,"","psexec \\" & $svrs[$i] & " -c ops.exe")
;         RunWait("psexec \\" & $svrs[$i] & " -c ops.exe","",@SW_HIDE)
Next

does that show you the Run String for each server?

Lar.

<{POST_SNAPBACK}>

thank you very much larry, script already works

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks guys, i had much help from this, i created a random word generator with your code.

;373709 words in my dictionary

#include <file.au3>
Dim $word 
If Not _FileReadToArray("dictionary.txt",$word) Then
   MsgBox(4096,"Error", " Dictionary.txt is missing  error:" & @error)
   Exit
EndIf

$x = Random (1, 373709, 1) 

    Msgbox(0,'Word: ' & $x, $word[$x])

Its of no use, but i wanted to tell you guys anyway :(

Edited by WhiteCrow

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