Jump to content
Baboo85

Send multiple commands line in a CMD window

Recommended Posts

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.

Edited by Baboo85

Share this post


Link to post
Share on other sites
Subz

Maybe something like:

;~ AdminInfo.ini
;~ [UserName]
;~ Username = Firstname Lastname
;~ [ComputerName]
;~ ComputerName = Domain

#NoTrayIcon
#include <Array.au3>
Global $bUserName = False, $bComputerName = False
Global $sErrorMsg = ""
Global $sAdminInfo = @ScriptDir & "\AdminInfo.ini"
    If FileExists($sAdminInfo) = 0 Then Exit

Global $aUserName = IniReadSection($sAdminInfo, "UserName")
    If @error Then Exit
If _ArraySearch($aUserName, @UserName, 0, 0, 0, 0, 1, 0) > 0 Then $bUserName = True

Global $aComputerName = IniReadSection($sAdminInfo, "ComputerName")
    If @error Then Exit
If _ArraySearch($aComputerName, @ComputerName, 0, 0, 0, 0, 1, 0) > 0 Then $bComputerName = True

MsgBox(0,'', "Username: " & $bUserName & @CRLF & "ComputerName: " & $bComputerName)

If $bComputerName And $bUserName Then
    MsgBox(0,'', 'test')
    RegDelete("HKLM\SOFTWARE\blahblabla", "RegValue")
Else
    If $bComputerName = False Then $sErrorMsg &= @ComputerName & " is not authorised" & @CRLF
    If $bComputerName = False Then $sErrorMsg &= @UserName & " is not authorised"
    MsgBox(4096, "Error", $sErrorMsg)
EndIf

 

Share this post


Link to post
Share on other sites
Baboo85
RegDelete("HKLM\SOFTWARE\blahblabla", "RegValue")

So this is the command to remove a key from the registry? Nice.

Thank you, I'll try this and I'll let you know, because I can't add files (AdminInfo.ini), I need to keep all into the exe file. I need an array.

It's inconvenient, but users shouldn't see anything.

Also I'll add the #RequireAdmin command

Edited by Baboo85

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

    • Docfxit
      By Docfxit
      I would like to know if there is a way to make the send cmd send characters when using
      Graphical AutoIt Debugger By Stumpii,
      If Not WinActive("Setup - UltraVNC","Setup is preparing to install") Then WinActivate("Setup - UltraVNC","Setup is preparing to install") WinWaitActive("Setup - UltraVNC","Setup is preparing to install") Send("{ALTDOWN}f{ALTUP}") ;Finish The debugger when using step mode will execute the Send cmd line but the window doesn't receive the input.
      Thanks,
      Docfxit
    • PoojaKrishna
      By PoojaKrishna
      Hi friends,
      I'm trying to send SHIFTDOWN, to keep the Shift key pressed until I close the program or releases the key.
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key manually and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down Agin", "Shift key is pressed again, now type something: ") In the above program sequence,
      1. Send SHIFTDOWN from program, Works as we type in the text are in Capital letters
      2. Manually presses and releases the SHIFT button. SHIFT key is released as when we type, text is in small letters only.
      3. Again send SHIFTDOWN from program, but not working. When we type the letters are in small letters.
       
      If we send a SHIFTUP  before  sending the SHIFTDOWN again, then it is working correctly and the text appears in capital letters only. Can any one explain why this happens?
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTUP}") sleep(100) Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is pressed, now type something: ")  
      Thank you.
    • TheDcoder
      By TheDcoder
      Hello everyone, long time since I made a post in the H&S sub-forum
      I am working on a project where in a situation I would have to hold down an arrow key and release it in another statement/command, however when I wrote the code it isn't working exactly like I thought it would. Here is an example:
      Send("{UP down}") Sleep(10000) Send("{UP up}") This should hold the up arrow key for 10 seconds before releasing it again, but when I run this code the cursor in SciTE moves up only once
      If I hold the up arrow manually for 10 seconds it "repeats" and the cursor moves up several times until I release the key... Is this a known limitation of Send? Is there any other way I can accomplish this?
      Thanks for all the help and feedback in advance! TD
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      With this script you can print Unicode text in the CMD screen
      the script is  easy to use
      just you  write the text that contains Unicode in the first input
      and the script automatically reflect the code in the second input
       you can copy the text to the clipboard
      or you can try printing the text in the CMD window
      I apologize to everyone for colors and shape if not appropriate
      I'm a blind man and I do not see
      Thank you for your understanding
      Greetings to all of youCmdUtM.au3
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry after your permission
      I found a function to get the special line commands for any operation
      It requires the name of the process to be searched
      I want to use it to know the process
      Is this possible with this function
      Here is the code
       
      Func commandLineGet($proc, $strComputer=".")
      dim $array[1]
      local $ArrayNumber
      local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
      local $oProcessColl = $oWMI.ExecQuery("Select * from Win32_Process where Name= " & '"'& $Proc & '"')
      local $Process
      For $Process In $oProcessColl
      $Process = $Process.Commandline
          ReDim $Array[UBound($Array)+1]
      $ArrayNumber = UBound($Array)-1
      $array[$ArrayNumber] = $Process
      Next
      $ArrayNumber = UBound($Array)-1
      $array[0] = $ArrayNumber
      return $array
      EndFunc
×