Sign in to follow this  
Followers 0
grumpyste

Script that works sometimes!

2 posts in this topic

I am new to AutoIt but have put together the following script:

#include<GUIConstants.au3>
#include<Process.au3>

AutoItSetOption("TrayIconHide", 1)

$tag = InputBox("Computer name changer", "This program will run NewSID then change all instances of ZYXWVUT found in the registry. Finally it will remove a registry key associated with McAfee antivirus." & @CRLF & @CRLF & "-----Please enter the TAG of the computer-----", "", " m")
If @error = 1 Then Exit

$tag = StringUpper($tag)

BlockInput(1)

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent", "AgentGUID")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "delsteve", "REG_SZ", "c:\temp\delete.bat")

$splash = GUICreate("", 500, 250, -1, -1, BitOR($WS_POPUP, $WS_DLGFRAME), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0x66FF66)
GUISetFont(20, 69)
GUICtrlCreateLabel("**********************", 10, 10, -1, -1, $SS_CENTER)
GUICtrlCreateLabel("NewSID is currently working.", 50, 50, -1, -1, $SS_CENTER)
GUICtrlCreateLabel("This may take up to 1 minute!", 100, 100, -1, -1, $SS_CENTER)
GUICtrlCreateLabel("Please be patient.", 150, 150, -1, -1, $SS_CENTER)
GUICtrlCreateLabel("***********************", 200, 200, -1, -1, $SS_CENTER)
GUISetState()

Run("c:\temp\newsid.exe /a /n " & $tag)
ProcessWaitClose("newsid.exe")
GUIDelete($splash)


;tried
$script = "c:\temp\regfind.exe -B ZYXWVUT -y -r " & $tag
_RunDOS($script)
Sleep(5000)

;also tried
$script = "c:\temp\regfind.exe -B ZYXWVUT -y -r " & $tag
$zyx = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOwner")

Do
    _RunDOS($script)
    Sleep(5000)
Until $zyx = $tag



BlockInput(0)

MsgBox(8192, "INFO:-", "The computer SID & name have been changed." & @CRLF & "All references to ZYXWVUT have been changed to " & $tag & @CRLF & @CRLF & "This computer must now restart - please click below to continue...")

Shutdown(6)

I then package the compiled code together with the needed tools: NewSID, Regfind and a batch file (used to delete the files in c:\temp after the PC restart) into a self extracting exe (using WinRAR) which when launched extracts the contents to c:\temp then launches the AutoIt script above.

The problem I am having is that the script seems to jump or miss out sections, the main one being parts refering to 'regfind'.

can anyone help me out please?

many thanks

steve

Share this post


Link to post
Share on other sites



The problem I am having is that the script seems to jump or miss out sections, the main one being parts refering to 'regfind'.

can anyone help me out please?

Welcome,

I am not accustomed to RegFind (Googled and found one with different syntax) but on a general note, you could try and use Comspec with the /k switch to see what it is finding with RegFind. Use below instead of your _RunDos($script) line. You will need to manually close each console window as it loops.

RunWait(@ComSpec & ' /k ' & $script)

That will comfirm your issue. You could also pipe the info to file within the command line and use /c instead of /k, so it would run without stopping.

:whistle:

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
Sign in to follow this  
Followers 0