FMS

Commandline function

5 posts in this topic

#1 ·  Posted (edited)

Hello,

I've made a GUI that can send multiple commands.
The way I'm doing this at the moment is whit "send" commands.
also first go to the right directory where the "to be used" program sits
And send from there the commandline argument whit parameters.

Here is a example of the way I'm using it now:

Func restart_app($xip)
   Run("C:\WINDOWS\system32\cmd.exe")
   WinWaitActive("C:\WINDOWS\system32\cmd.exe")
   Sleep(50)
   send("cd\" & "{ENTER}")
   Sleep(50)
   send("cd Tools" & "{ENTER}")
   Sleep(50)
   send("pskill \\" & $$xip & " -u username -p pass /accepteula app.exe" & "{ENTER}")
EndFunc

This way is working and I got no problems whit this.
Also I realy think there is a mush better and way to do the same and maybe a little bit less error free :)
(even better if this is hidden for the user :))
On this forum I could not find anything related to this subject (or I was not looking in the right direction) and hope somebody knows a better way :)

Is there a way where u can send the arguments and parameters directly in 1 line to the commandpromt whitout using "send" to commandprompt?

Thanks in advanced

ps: I also tried :

ShellExecute("pskill", "\\" & $xip & " -u username -p pass /accepteula app.exe")

But din't work

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites




Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

@Skitty

Thanks , this was indeed what i was looking for.
For futher referense :
 

RunWait(@ComSpec & " /k " & "pskill \\" & $xip & " -u username -p pass /accepteula posclient.exe"  , "C:\tools",@SW_HIDE )

/k is for debugging....


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

Hi.

PSKILL.EXE does *NOT* need a @comspec shell to execute,

And " /k " instead of " /c " just doesn't exit the comspec shell after the called program terminated.

 

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Good luck:

Func _PsKill($AppName, $IP = "", $Uname = "", $PassWord = "")
    If StringStripWS($AppName, 8) = "" Then Return SetError(1, 0, 0)
    Local $sCommand, $PsKillEXE = @ScriptDir & "\pskill.exe"
    If $IP <> "" Then $sCommand &= " \\" & $IP
    If $Uname <> "" Then $sCommand &= ' -u ' & $Uname & ''
    If $PassWord <> "" Then $sCommand &= ' -p "' & $PassWord & '"'
    $sCommand &= " /accepteula " & $AppName
;~  RunWait('"' & $PsKillEXE & '" ' & $sCommand, @ScriptDir, @SW_HIDE)
    ShellExecute($PsKillEXE, $sCommand, @ScriptDir, "", @SW_HIDE)
EndFunc   ;==>_PsKill

 


Regards,
 

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

  • Similar Content

    • TheDcoder
      By TheDcoder
      Hello Everyone , Are you tired of searching the forum for getting both the exit code & the stdout output? Then you are in the right place!

      With this UDF you can get the both output & exit code of the command or the console app! Or you can get the exit code of another process without having to use RunWait...
      Features:
      1. Simple & Lightweight (15 KB)
      2. Detailed comments & description
      3. Flexible functions with many optional parameters
      A BIG THANKS TO PsaltyDS for the functions! 2 of the (main) functions in the UDF are his work
       
      List of functions:
      Downloads:
      Grab the latest (in development) code from GitHub
       
      Hope it may help you, TD
       
      P.S Icon made by Freepik from www.flaticon.com, Modified by TheDcoder
    • spuuunit
      By spuuunit
      This is what I'm trying to do: In Firefox, if you hold down CTRL + C for about 200ms, then press CTRL + T. This is my code:
      While WinActive(" - Mozilla Firefox") If _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Then $timer = TimerInit() While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) $diff = TimerDiff($timer) If $diff > 200 Then Send("^{T}") While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) WEnd EndIf WEnd EndIf WEnd The problem is that the CTRL key gets stuck down after Send("^{T}"). I found this, but what I understand that happens when I release, and that is not what I want. The "General unstuck method" did nothing.
    • Baboo85
      By Baboo85
      Hi all,
      I need to start a script that include:
      - admin privileges
      - multiple cmd commands
      - no bat, no exe, no tmp files created anywhere (especially in the user temp folder)
      In a bat file it would be simple, but users shouldn't see what commands I'm sending.
      Example of the script:
      echo off cls echo. echo I AM A TOOL echo. echo NOTE: echo - note 1 echo - note 2 echo - etc set USER1=0 set COMPUTER1=0 if /i %username% equ user.user ( set USER1=1 set COMPUTER1=1 ) if /i %username% equ another.user set USER1=1 if /i %computername% equ notebook set COMPUTER1=1 if %USER1% EQU 1 ( if %COMPUTER1% EQU 1 ( reg delete "HKLM\SOFTWARE\blablabla" /f ) else ( echo Computer not authorized. Contact assistance.) ) else ( echo User not authorized. Contact assistance.) echo. pause exit With the send("") is a disaster.
      I'm a noob here, so what can I do?
       
      EDIT: OR ELSE I explain the situation and what I need, so if there is a simple solution I can use that.
       
      SITUATION: our domain users have Users rights on the machine. Some of them need administrator rights.
      We create a local user with administrator rights, so that the users must insert username and password when asked to run something with administrator rights.
      We have an internal domain group policy that blocks EXE, BAT, COM, TMP files from the user local temp directory, for a security reason (malware). That also blocks most software installation.
      But some users are often out of office, away from workplace and in another country, they need a complete control on their computers.
       
      WHAT I NEED: I need to check the username and the computer name. If the username is the one with local administrator rights and the computer name is a computer that is qualified to temporary remove the policy, then I need to execute a REG DELETE command with administrator rights.
       
      I hope I explained myself.
       
      Thank you very much.
    • Jefrey
      By Jefrey
      I've made this HTTP lib to simplify HTTP requests, mainly when dealing about POST data or file uploads.
      Three functions are available:
      string _HTTP_Get ( string $sURL ) string _HTTP_Post ( string $sURL , string $sPostData ) string _HTTP_Upload ( string $sURL , string $sFilePath , string $sFileField , string $sPostData = '' , string $sFilename = Default) Additionaly, two helper functions are also available:
      URLEncode($sStr) URLDecode($sStr) Full documentation: https://github.com/jesobreira/HTTP.au3/blob/master/README.md
      Fork me on Github: https://github.com/jesobreira/HTTP.au3
      Download lib + docs: https://github.com/jesobreira/HTTP.au3/archive/master.zip
    • caramen
      By caramen
      Hello guys.
      I have got this script
      $iPid = run("Powershell Get-ADUser "&$UserNameReaded&" -Properties * | select -Expand EmailAddress" , @WindowsDir , @SW_HIDE , 0x2) $MailUser = "" While 1 $MailUser &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd GUICtrlSetData ($Label015, ""&$MailUser) If $MailUser = "" Then GUICtrlSetData ($Label017 , "N/A"&$MailUser) Everything is working fine i got correct value
      For my account the value is for exemple :
      J.Personnal@Enterprise.com in the $Label017 the value is correct i have still
      J.Personnal@Enterprise.com If i use :
      Send (""&$MailUser) i have now :
      J.Personnalnterprise.com Is there a way to correct this ?