Jump to content

Dos command not working and function input query


raj_crc
 Share

Recommended Posts

Hi, its a simple script to enter whatever someone types into a dos command that autoit will run, however when testing pre inputing the user information the dos command doesnt work ? Also can someone tell me how i would use the input from the line :

$txt_pcname = GuiCtrlCreateInput("Asset or ip Here", 30, 50, 190)

to put the text they type into the dos command, e.g. the dos command should be :

C:\apps\ConsoleOne\1.3.6\bin\zen\RcLaunch\RCConsole.exe -n"KINGSTON" -c"Remote Control" -t"0" -s"2" -a%usrtext% -p"npgb"

where %usrtext% would be equal to the $txt_pcname got from the line ( $txt_pcname = GuiCtrlCreateInput("Asset or ip Here", 30, 50, 190) )

oh, i've jumped ahead, the basic dos command with no variables in it doesnt work,

Run("C:\apps\ConsoleOne\1.3.6\bin\zen\RcLaunch\RCConsole.exe -n"KINGSTON" -c"Remote Control" -t"0" -s"2" -aHS0986b -p"npgb"")

when i goto windows -> start -> run and copy paste the command line it works :

C:\apps\ConsoleOne\1.3.6\bin\zen\RcLaunch\RCConsole.exe -n"KINGSTON" -c"Remote Control" -t"0" -s"2" -aHS0986b -p"npgb"

--------------------------script start--------------------------------

; ----------------------------------------------------------------------------

;

; AutoIt Version: 3.1.0

; Author: raj <raj@king.ac.uk>

;

; Script Function:

; AutoIt script.

;

; ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

$mainwindow = GUICreate("CRC", 260, 140)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUICtrlCreateLabel("Remote control - Raj DEC 2006", 20, 10)

$txt_pcname = GuiCtrlCreateInput("Asset or ip Here", 30, 50, 190)

$remote =GUICtrlCreateButton("Remote control workstation", 30, 90, 190)

GUICtrlSetOnEvent($remote, "remote")

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISwitch($mainwindow)

GUISetState(@SW_SHOW)

While 1

Sleep(1000) ; Idle around

WEnd

Func remote()

;Note: at this point @GUI_CTRLID would equal $okbutton

Run("C:\apps\ConsoleOne\1.3.6\bin\zen\RcLaunch\RCConsole.exe -n"KINGSTON" -c"Remote Control" -t"0" -s"2" -aHS0986b -p"npgb"")

EndFunc

Func CLOSEClicked()

;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,

;@GUI_WINHANDLE will be either $mainwindow or $dummywindow

If @GUI_WINHANDLE = $mainwindow Then

Exit

EndIf

EndFunc

--------------------------script end--------------------------------

cheers for the help in advance :P

Link to comment
Share on other sites

You messed up the " quotes in the run command, best to use ' single quotes to enclose the command and " double quotes where you acctually need them. Also read the input with guictrlread() and parse it into the command enclosed in &'s... might work now :P...

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author: raj <raj@king.ac.uk>
;
; Script Function:
; AutoIt script.
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode 
$mainwindow = GUICreate("CRC", 260, 140)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Remote control - Raj DEC 2006", 20, 10)
$txt_pcname = GuiCtrlCreateInput("Asset or ip Here", 30, 50, 190)
$remote =GUICtrlCreateButton("Remote control workstation", 30, 90, 190)
GUICtrlSetOnEvent($remote, "remote")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

While 1
Sleep(1000); Idle around
WEnd

Func remote()
;Note: at this point @GUI_CTRLID would equal $okbutton
    Run('C:\apps\ConsoleOne\1.3.6\bin\zen\RcLaunch\RCConsole.exe -n"KINGSTON" -c"Remote Control" -t"0" -s"2" -a' & guictrlread($txt_pcname) & ' -p"npgb"')
;MsgBox(0,"",'C:\apps\ConsoleOne\1.3.6\bin\zen\RcLaunch\RCConsole.exe -n"KINGSTON" -c"Remote Control" -t"0" -s"2" -a' & guictrlread($txt_pcname) & ' -p"npgb"')
EndFunc

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
    If @GUI_WINHANDLE = $mainwindow Then 
        Exit
    EndIf 
EndFunc
This post will be edited again by Polyphem: Tomorrow, 11:55 AM
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...