Jump to content

Having trouble passing arguments to PsExec


jeebz
 Share

Recommended Posts

Hi,

A little background to begin with:

I have created a script that pretty much launches camtasia player on several remote hosts, records for about 3 minutes, then stops recording. It then transfers the files to a shared network drive.

My issue is that, on SOME machines, it seems like my program is not sending the argument to PsExec as it should be.

The line of code is as follows:

$RecLaunch = Run(@ComSpec & " /c C:\pstools\psexec.exe \\" & $target & ' -u mumbojumbo -p blahblahblah -w C:\tapes\ -c -f -d -i 0 "' & $RecorderPath64 & '" ' & $eventname, "C:\PsTools", @SW_HIDE)

This works perfectly fine on MY computer (same OS as other machines I am trying to run this from), and same version of PsTools.

I get a bad variable error when it tries to call $CmdLine[1]...which makes no sense to me since it works perfectly fine on my computer.

Actual error message : ERROR : Array variable has incorrect number of subscripts or subscript dimension range exceeded.

My question is has anyone actually had this problem before?

I feel like I need to post more of my code....here it goes:

In the GUI

While 1[/size][/size]
Local $lClick[/size]
[size=4]$lClick = GUIGetMsg()[/size]
[size=4]Switch $lClick[/size]
[size=4]  Case $GUI_EVENT_CLOSE
   ConsoleWrite(_GUICtrlComboBox_GetEditText($EventListBox))
   Exit[/size]
[size=4]  Case $StartAllButton
   ;If _CheckDailyRunning("192.168.0.10") Then _StopDailyRec("192.168.0.10")
   For $i = 0 to UBound($HostList) - 1
    GUICtrlSetData($HostList[$i][2], "Starting...")
    _StartEventRec($HostList[$i][1], _GUICtrlComboBox_GetEditText($EventListBox))
   Next
EndSwitch
WEnd[/size]
[size=4]Func _StartEventRec($target, $eventname)
If _IsTheComputerOn($target) Then
  If $target = "192.168.0.11" or $target = "192.168.0.10" Then
   $RecLaunch = Run(@ComSpec & " /c C:\pstools\psexec.exe \\" & $target & ' -u mumbojumbo -p blahblahblah -w C:\tapes\ -c -f -d -i 0 "' & $RecorderPath64 & '" ' & $eventname, "C:\PsTools", @SW_HIDE)
  Else
   $RecLaunch = Run(@ComSpec & " /c C:\pstools\psexec.exe \\" & $target & ' -u mumbojumbo -p blahblahblah -w C:\tapes\ -c -f -d -i 0 "' & $RecorderPath32 & '" ' & $eventname, "C:\PsTools", @SW_HIDE)
  EndIf
Else
  MsgBox(0, "Error", "Unable to start tape on " & $target, 10)
EndIf
EndFunc

In the autoit script that gets launched on the other end:

[/size]
Global $folderdate = " - " & @YEAR & "-" & @MON & "-" & @MDAY
Global $filedate = "_" & $Month & @MDAY & "_"
Global $destcountry = StringLeft($cmdline[1], 2)
 
$tapeslist = _FileListToArray("C:\Tapes")
_ArraySort($tapeslist, 1)
 
DriveMapDel("X:")
Sleep(5000)
DriveMapAdd("X:", "\\rbcfs02.hahahoohoo.com\Blahblah", 1, "blah\bloo", "beebop")
 
Global $source = '"C:\Tapes\' & $tapeslist[0] & '"'
Global $destination = "\\rbcfs02.hahahoohoo.com\Blahblah\TTTaping\" & @YEAR & "\" & $destcountry & "\" & $cmdline[1] & "\" & $cmdline[1] & $folderdate
Global $newfilename = $cmdline[1] & $filedate & @ComputerName & ".avi"
 
;MsgBox(0,"filemove", "Source: " & $source & @CRLF & "Destination: " & $destination & "\" & $newfilename & @CRLF)
If Not FileExists($destination) Then RunWait(@ComSpec & " /c md " & '"' & $destination & '"', "", @SW_SHOW)
$FMove = RunWait(@ComSpec & " /c copy " & $source & ' "' & $destination & "\" & $newfilename & '"', "", @SW_SHOW)
[size=4]

Please note this isnt the whole code...there are chunks missing of course :graduated:

and i have replaced IPs and users/password with dummy info.

Any help would be GREATLY appreciated.

Thank you!!

edit: I forgot to mention that PsExec will actually launch the other autoit script on the remote hosts, but it fails on the first line that $CmdLine[1] is called. It feels like the argument ($eventname)is not being sent.

I have tried using ShellExecute, Run, RunWait, ShellExecuteWait to do this and they have all failed. I have tried with and without a working directory as well.

Edited by jeebz
Link to comment
Share on other sites

Hi Jeebz,

I'm a noob too however if you look at a problem I had with passing a SQL string... you might be able to use the same solution... (yes I know you are not using SQL)

look here...

What I did was make up the command line first using all the variables into a "hard coded" command as a variable, and then send THAT one variable that did not have any other variables in it. It worked for me in a SQL statement that would not work any other way.

Possibly try it...

Let me know how you go.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...