Jump to content
Sign in to follow this  

Having trouble passing arguments to PsExec

Recommended Posts



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
[size=4]  Case $StartAllButton
   ;If _CheckDailyRunning("") Then _StopDailyRec("")
   For $i = 0 to UBound($HostList) - 1
    GUICtrlSetData($HostList[$i][2], "Starting...")
    _StartEventRec($HostList[$i][1], _GUICtrlComboBox_GetEditText($EventListBox))
[size=4]Func _StartEventRec($target, $eventname)
If _IsTheComputerOn($target) Then
  If $target = "" or $target = "" 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)
   $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)
  MsgBox(0, "Error", "Unable to start tape on " & $target, 10)

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

Global $folderdate = " - " & @YEAR & "-" & @MON & "-" & @MDAY
Global $filedate = "_" & $Month & @MDAY & "_"
Global $destcountry = StringLeft($cmdline[1], 2)
$tapeslist = _FileListToArray("C:\Tapes")
_ArraySort($tapeslist, 1)
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)

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

Share this post

Link to post
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.

Share this post

Link to post
Share on other sites

Hi Bendo,

Thanks for the suggestion.

I just gave it a try and it did not work :graduated:

Back to the drawing board!

Share this post

Link to post
Share on other sites

I might just add a function to have my original GUI write the parameter to a file, and then the remotely launched application will query the file....

I was hoping to find a solution to this though in some other way...

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