Jump to content

EllisDee

Members
  • Posts

    7
  • Joined

  • Last visited

About EllisDee

  • Birthday April 7

Profile Information

  • Location
    Brisbane, Australia

EllisDee's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Regarding the MAC address, its just to have it on screen if the person deploying hasn't already contacted the department to add it to network.
  2. Hi all, First of all, not sure whether to post this here or example scripts as although it works it does have a problem This is my first script I have made with AutoIT, its very basic but does some deployment tasks to make my life easier. Script: 2 Questions: 1, Why doesn't this part work? If the Computer has a floppy disk, the script still tries to read it even though I have specified no A:\ When it tries to read A:\ the files do not copy from the usb stick & then the script continues to add users to admins. ; Locate USB Drive & assigned drive letter, then copy files. $var = DriveGetDrive( "removable" ) If NOT @error Then For $i = 1 to $var[0] If $var[$i] = "a:" Then ContinueLoop $usbdrive = $var[$i] 2, Can you suggest any improvements to the code, as I've said this is my first one and I've never tried scripting before.
  3. Hi, I don't see how this helps my situation as you have used the code "netsh interface show interface" rather than "netsh interface tcp set global autotuning=disabled" If I use your autoit script with the correct code I notice that the problem where the command prompt is not being run in elevated mode still exists. #include <Constants.au3> #requireadmin Local $foo = Run(@ComSpec & " /c netsh interface tcp set global autotuning=disabled", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = $line & StdoutRead($foo) If @error Then ExitLoop WEnd MsgBox(0, "STDOUT read:", $line) $line = "" While 1 $line = $line & StderrRead($foo) If @error Then ExitLoop WEnd If $line <> "" Then MsgBox(0, "STDERR read:", $line) Else MsgBox(0, "STDERR read:", "No output from STDERR!") EndIf
  4. Thanks for the replies, Unfortunatly this is not enough, I have already tried the #requireadmin command in my original script. I have removed quotes however cmd.exe still doesn't run with elevated permission, this could be a problem with the localadmin ID & psw however. I've done some more research on this: A site with information regarding autotuning network card & commands: http://www.speedguide.net/faq_in_q.php?qid=247 I have tried using this: however my script doesn't run after the elevate pop up window. I have tried this: http://www.fanhow.com/answers/question-6...-Command-Prompt-Shortcut-in-Wi using the following: #include <Constants.au3> #requireadmin Local $foo = Run("C:testelevate.exe %windir%system32cmd.exe" & " /c netsh interface tcp set global autotuning=disabled", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = $line & StdoutRead($foo) If @error Then ExitLoop WEnd MsgBox(0, "STDOUT read:", $line) However the stdout pop up is just blank. (Elevated Command prompt.exe can be downloaded here: http://www.sevenforums.com/tutorials/3718-elevated-command-prompt-shortcut.html) This site (http://blogs.msdn.com/b/tims/archive/200...ed-command-prompt-in-six-keyst) explains how to open the cmd.exe window with elevated privileges which is why initially I was doing the keystroke approach ; Deployment Script ; This script requires full Administrative rights #requireadmin ; Get the MAC Address of the computer Send ("{LWin}") Send ("cmd.exe") Send ("{ENTER}") WinWait ("C:\Windows\System32\cmd.exe") Send ("ipconfig /All") Send ("{ENTER}") ; Check if Corp. IS&T have been contacted $yesnobox = MsgBox(4, "Check!", "Have you registered the MAC# with Corporate IS&T for ACS (Authentication)") If $yesnobox = 7 Then Exit Else ; Disable Autotuning on network card Send ("{LWin}") Send ("cmd.exe") Send ("{CTRLDOWN}{SHIFTDOWN}{ENTER}") WinWait ("Administrator: C:\Windows\System32\cmd.exe") Send ("{CTRLUP}{SHIFTUP}") Send ("cls") Send ("{ENTER}") Send ("netsh interface tcp set global autotuning=disabled") Send ("{ENTER}") Send ("Exit") Send ("{ENTER}") EndIf The above works, but I wanted some sort of error checking, so when the netsh command is run the output from the command window will either be "OK." (continue with script) or "Set global command failed on IPv4 The requested operation requires elevation" (Stop script, report error in a pop up)
  5. I think I'm getting somewhere. The problem is I am trying to run the netsh command. This requires the cmd.exe window opened with elevated privalages, this is why I had: Send ("{LWin}") Send ("cmd.exe") Send ("{CTRLDOWN}{SHIFTDOWN}{ENTER}") WinWait ("Administrator: C:\Windows\System32\cmd.exe") Send ("{CTRLUP}{SHIFTUP}") Send ("cls") Send ("{ENTER}") Send ("netsh interface tcp set global autotuning=disabled") Send ("{ENTER}") However I'm guessing with the stdreadout command you have to write it as you did in your previous post. I have looked here: And I still cannot get cmd.exe to run elevated. I have tried a modification of the code you wrote so it ask's for ID & Psw. Note that I am on a domain, however if asking for local admin ID & Psw I would assume I use the @computername command rather than mydomainnname #include <Constants.au3> #requireadmin $username = InputBox("Local Admin ID Required", "Please enter Username") $pw = InputBox("Local Admin Psw Required", "Please enter Password", "", "*") Local $foo = RunAs("$username", @ComputerName, "$pw", 2, @ComSpec & " /c netsh interface tcp set global autotuning=disabled", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = $line & StdoutRead($foo) If @error Then ExitLoop WEnd MsgBox(0, "STDOUT read:", $line) The STDOUT Message I'm receiving with the above code is: Set global command failed on IPv4 The parameter is incorrect. This error message indicates that cmd.exe has not run with elevated permission. I'm about to finish work today however I will be back on tomorrow, Thanks again for help!
  6. Hi thanks for the reply, I'm not sure how to use stdoutread to look for OK. when cmd.exe opens and the netsh command is run & if it sees OK. to continue or if cmd.exe shows an error then to display a msg box, I'm assuming the latter is going to be a IF/Else command. Also the help file mentions a $pid, im not sure where to put this in the code I have created. Thanks,
  7. Hey, I'm having trouble with this script I'm writing. ; Deployment Script ; This script requires full Administrative rights #requireadmin ; Get the MAC Address of the computer Send ("{LWin}") Send ("cmd.exe") Send ("{ENTER}") WinWait ("C:\Windows\system32\cmd.exe") Send ("ipconfig /All") Send ("{ENTER}") ; Check if Corp. IS&T have been contacted $yesnobox = MsgBox(4, "Check!", "Have you registered the MAC# with Corporate IS&T for ACS (Authentication)") If $yesnobox = 7 Then Exit Else ; Disable Autotuning on network card Send ("{LWin}") Send ("cmd.exe") Send ("{CTRLDOWN}{SHIFTDOWN}{ENTER}") WinWait ("Administrator: C:\Windows\system32\cmd.exe") Send ("{CTRLUP}{SHIFTUP}") Send ("cls") Send ("{ENTER}") Send ("netsh interface tcp set global autotuning=disabled") Send ("{ENTER}") $CheckcmdWindow StringInStr ( "Administrator: C:\Windows\system32\cmd.exe", "OK.") If $CheckcmdWindow = 1 Then Send ("exit") Send ("{ENTER}") Else MsgBox(0, "Error", "Autotuning the network card failed") EndIf EndIf Please bear in mind I have no programming experiance or scripting experiance, I figured autoit was the simplest way to learn. You may notice the code is basic, if you can suggest ways to improve it, it would be appreciated. Basically my problems is with the stringinstr command, I cannot seem to get it to read the OK. at the end of the command prompt to verify whether autotuning worked or not. I have checked here and here But don't really understand how to resolve my issue. Any help is gratefully received,
×
×
  • Create New...