Jump to content

Run Command Syntax


Recommended Posts

i am trying to add a network printer with a script. i can do it with a batch file but i am trying to use autoit.

_RunDos("rundll32 printui.dll,PrintUIEntry /ga /c\\" & $inputComputer "/n\\" & $inputPrinter)

here is the dos command:

rundll32 printui.dll,PrintUIEntry /ga /c%computer% /n%printer%

Edited by antmar904
Link to comment
Share on other sites

Perhaps you forgot #include <Process.au3>

Also, I see that it should be

" /n" & $inputPrinter)

You forgot a space before...

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#Region ### START Koda GUI section ### Form=
$form1 = GUICreate("Remote Printer Install", 377, 448, 389, 345)
$inputComputer = GUICtrlCreateInput("D9042", 88, 32, 201, 21)
$inputPrinter = GUICtrlCreateInput("server\printer", 88, 64, 201, 21)
$lblComputer = GUICtrlCreateLabel("Computer", 32, 40, 49, 17)
$lblPrinter = GUICtrlCreateLabel("Printer", 32, 72, 42, 17)
$btnStart = GUICtrlCreateButton("Start", 208, 104, 75, 25)
$grpInstall = GUICtrlCreateGroup("Install Printer", 16, 8, 345, 145)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $btnStart
   _RunDos("rundll32 printui.dll,PrintUIEntry /ga /c\\" & $inputComputer " /n\\" & $inputPrinter)
EndSwitch
WEnd

Link to comment
Share on other sites

My last try: _RunDos('rundll32 printui.dll,PrintUIEntry /ga /c"' & $inputComputer '" /n"' & $inputPrinter & '"')

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Oh, I realize it now: it should be GUICtrlRead($inputComputer) and not just $inputComputer. same goes with $inputPrinter as well.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

ok i added that but it is still giving me a syntax error

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#Region ### START Koda GUI section ### Form=
$form1 = GUICreate("Remote Printer Install", 377, 448, 389, 345)
$inputComputer = GUICtrlCreateInput("D9042", 88, 32, 201, 21)
$inputPrinter = GUICtrlCreateInput("server\printer", 88, 64, 201, 21)
$lblComputer = GUICtrlCreateLabel("Computer", 32, 40, 49, 17)
$lblPrinter = GUICtrlCreateLabel("Printer", 32, 72, 42, 17)
$btnStart = GUICtrlCreateButton("Start", 208, 104, 75, 25)
$grpInstall = GUICtrlCreateGroup("Install Printer", 16, 8, 345, 145)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $btnStart
   Local $computer = GUICtrlRead($inputComputer)
   Local $printer = GUICtrlRead($inputPrinter)
     _RunDos('rundll32 printui.dll,PrintUIEntry /ga /c\\"' & $computer '" /n\\"' & $printer & '"')
EndSwitch
WEnd
Link to comment
Share on other sites

At last:

_RunDOS('rundll32.exe printui.dll,PrintUIEntry /ga /c\\' & $computer & ' /n\\' & $printer)

A single missing '&' sign created so many posts

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

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

×
×
  • Create New...