Sign in to follow this  
Followers 0
Carm01

RunAsWait not accepting variable from drop and drag path

3 posts in this topic

Hello,

I am trying to create a way to drop and drag a file path using some examples in the help and then take that variable and pass it on to a runaswait so i can run whatever program i want with specified user rights.

This problem i cant seem to get around is the fact that the variable $file is retained when drop and drag is preformed, however the runaswait command does not seem to recognize it, as a result no program is ran , but the message box shows that the variable retains the path ( message box used used for testing of script ).

I spend a few hours trying various things to try to resolve this including trying to include quotes in the variable path, changing passing the $file to another variable, and several more. 

Odd enough if I set the variable it works, but defeats the purpose of being able to choose any program to run with a specified account ( this is for a domain environment, however should function the same on local account ) 

Any assistance is appreciated

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
; Change the username and password to the appropriate values for your system.
Local $sUserName = "username"
Local $sPassword = "password"

    Local $file, $btn, $msg

GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, $WS_EX_ACCEPTFILES)
$qwerty = GUICtrlCreateInput("", 10, 5, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
;GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files
$btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

GUISetState(@SW_SHOW)

    $msg = 0

    While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
ExitLoop
EndSelect
WEnd



RunAsWait($sUserName, @ComputerName, $sPassword, 0, $file, "", @SW_SHOWMAXIMIZED)

    MsgBox($MB_SYSTEMMODAL, "drag drop file", GUICtrlRead($file))


EndFunc ;==>Example

 

 

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