Sign in to follow this  
Followers 0
Rahul Rohela

Not getting required result

3 posts in this topic

HI all,

I have created one script to execute Psexec ( Dwonload from www.sysinternals.com )..

Script is working fine for first GO.. But if i change options or click cancel at message box its giving problem

Problem is its not executing command with all checked, filled or selected options..

Please help to resolve this

*****************Part of Script To get result************

Func RunSc()

if GUICtrlRead ($PCName) = 1 then

$PCName = GUICtrlRead ($PCid)

Else

$PCName = ""

EndIf

if GUICtrlRead ($UserName) = 1 then

$UserName = " -u " & GUICtrlRead ($UserID)

Else

$UserName = ""

Endif

if GUICtrlRead ($UPwd) = 1 then

$UPwd = " -p " & GUICtrlRead ($password)

Else

$UPwd = ""

Endif

if GUICtrlRead ($DisplayAll) = 1 then

$DisplayAll = " -s "

Else

$DisplayAll = ""

Endif

if GUICtrlRead ($DisplayEthernet) = 1 then

$DisplayEthernet = " -e "

Else

$DisplayEthernet = ""

Endif

if GUICtrlRead ($UseNumeric) = 1 then

$UseNumeric = " -i "

Else

$UseNumeric = ""

Endif

if GUICtrlRead ($IncludePID) = 1 then

$IncludePID = " -c "

Else

$IncludePID = ""

Endif

if GUICtrlRead ($ByProtocol) = 1 then

$ByProtocol = " -f "

Else

$ByProtocol = ""

Endif

if GUICtrlRead ($VersionN) = 1 then

$VersionN = " -v "

Else

$VersionN = ""

Endif

if GUICtrlRead ($TermiNate) = 1 then

$TermiNate = " -d "

Else

$TermiNate = ""

Endif

if GUICtrlRead ($AppFile) = 1 then

$AppFile = GUICtrlRead ( $FileIn)

Else

$AppFile = ""

Endif

if GUICtrlRead ($ShowConnections) = 1 then

$ShowConnections = " -priority " & GUICtrlRead ($ConProtocol)

Else

$ShowConnections = ""

Endif

if GUICtrlRead ($Pause) = 1 then

$Pause = " -a " & GUICtrlRead ($Interval)

Else

$Pause = ""

Endif

Call ("CmdRun")

EndFunc

Func CmdRun()

;****************main command

StringIsSpace($Pram1)

$Pram1 = $PCName & $UserName & $UPwd & $DisplayAll & $DisplayEthernet & $UseNumeric & $IncludePID & $ByProtocol & $VersionN & $TermiNate & $AppFile & $ShowConnections & $Pause

$CommandLine = "psexec " & $Pram1

;msgbox(0,"test", $CommandLine)

$RunCom = MsgBox (1, "This is the psexec command that you just configured:", "Do you want to execute it " & Chr(13) & Chr(13) & $CommandLine & Chr(10) & Chr(10))

If $RunCom = 1 Then

RunWait ( "cmd /t:9f /k" & $CommandLine )

Else

GUICtrlSetState ( $PCName, $GUI_FOCUS )

EndIf

EndFunc

In first run Valu of $CommandLine is as per selection But in second time Its only gving vale "PSEXE"... What ever the selection is....

GUISetState (@SW_SHOW)

While 1

$msg = GUIGetMsg()

Select

;If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Case $msg = $GUI_EVENT_ClOSE

Exit

Case $msg = $Closedown

Exit

Case $msg = $DisplayHelp

RunWait ( "cmd /t:9f /k Psexec /?" ) ;***********Command execute*******

Case $msg = $ProcessOptions

Call("RunSc")

EndSelect

Wend

Share this post


Link to post
Share on other sites



The main issue is: you're re-using critical variables...

if GUICtrlRead ($PCName) = 1 then

$PCName = GUICtrlRead ($PCid)

Else

$PCName = ""

EndIf

If you're using GUICtrlRead() properly, then $PCName should be the Control ID. You're assigning it a string value, which will prevent you from further using it to read the control contents.

Use different variables.

The rest of my post is mostly aesthetic and won't affect the overall results of your code.

It's simpler to run functions directly. Replace:

Call ("CmdRun")

with:
CmdRun()
Similarly, you can replace Chr(13)/Chr(10) with the @CR/@LF macros.

This line does nothing:

StringIsSpace($Pram1)

Use an If statement or assign the result to a variable.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

The main issue is: you're re-using critical variables...

QUOTE(Rahul Rohela @ Oct 12 2005, 04:56 AM)

if GUICtrlRead ($PCName) = 1 then

$PCName = GUICtrlRead ($PCid)

Else

$PCName = ""

EndIf

Please give one example i am new to it creating this script for last 10 days......

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