Jump to content

Help with CMD window and passing key commands


Recommended Posts

HELP!!!

Is there a way with AutoIt to use the Windows Command window but not show the "send" command key sequence sent to it??

I have a script that I am using to change the Computer Name on a "non-domain" Windows XP computer, using the WMIC program, but the problem is sending the key strokes because it displays the Administrators password.

Can the Sent key commands be maksed or hidden in any way? I've tried the Run command with the @SW_HIDE, and @SW_MINIMIZED flags, but of course, it doesn't work.

Func RenameComputer()
$NewName = "TEST"
$Admin = "Administrator"
$Password = "xxxxxxxx"
$WMIC = 'COMPUTERSYSTEM where "Name=' & "'" & @ComputerName & "'" & '"' & " CALL Rename " & $NewName & ", $Password, $Admin" 
 SplashTextOn("", "" & @CR & "Please wait...", 250, 80, -1, -1, 0, "Arial", 14, 400)
 Run("C:\WINDOWS\system32\wbem\wmic.exe", "C:\WINDOWS\system32\wbem", @SW_SHOW)
 Sleep(1000)
 Send($WMIC)
 Send("{Enter}")
 Sleep(1000)
 Send("y")
 Send("{Enter}")
 Sleep(1000)
 Send("exit")
 Send("{Enter}")
 Sleep(1000)
 SplashOff()
 Shutdown(3)
EndFunc
Edited by HockeyFan
Link to comment
Share on other sites

Run("C:\WINDOWS\system32\wbem\wmic.exe", "C:\WINDOWS\system32\wbem", @SW_SHOW)

why do you use wmic.exe? You can use WMI directly with AutoIT. Search the forum for wmi and you will find a lot of samples, including the ones to change the host name.

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Thanks...I'll check it out!

see this post: http://www.autoitscript.com/forum/index.ph...ost&p=82253

WARNING: The password is still in the script!!

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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...