Jump to content

Register/UnRegister


JGBJGB
 Share

Recommended Posts

;

; AutoIt Version: 3.0

; Language: English

; Platform: Win9x/NT

; Author: James Borak

;

; Script Function:

; Allow the user to Register or Unregister the file they specify.

;----------------------------------------------------

Dim $message ;Declare any variables needed by this program.

Dim $File

Dim $Register

Dim $UnRegister

;----------------------------------------------------

WinMinimizeAll ( ) ;Minimize all the windows while this script executes.

;Title for the File Open dialog.

$message = "Choose the file you would like to Register or Unregister."

;Show the user the file open dialog.

;Options 1 = File Must Exist (if user types a filename), 2 = Path Must Exist (if user types a path).

$File = FileOpenDialog($message, @SystemDir & "\System32", "Components (*.dll;*.ocx)", 1 + 2 )

;If there were any errors or the user did not choose a file then get out.

If @error Then

MsgBox(4096,"Register/UnRegister","No File was chosen - Exiting",10)

WinMinimizeAllUndo ( ) ;Restore all windows to their original positions.

Exit ;Stop Execution.

EndIf

;Ask the user if they want to register the file.

;If they answer yes then register the file.

;Else, If the answer is no then ask them if they want to unregister the file.

;If they answer yes then inregister the file.

;Else, If they answer no to that then ask them why they are using this program - just kidding.

$Register = MsgBox(4, "Register/UnRegister", "------------------REGISTER------------------" & @CRLF & _

"Hit Yes to Register..." & @CRLF & $File)

If $Register = 6 Then ;The user answered Yes to the Register the file question.

RunWait('regsvr32 /s "' & $File, @SystemDir)

Else ;The user answered No to the Register the file question.

$UnRegister = MsgBox(4, "Register/UnRegister", "----------------UNREGISTER------------------" & @CRLF & _

"Hit Yes to UnRegister..." & @CRLF & $File)

If $UnRegister = 6 Then ;The user answered Yes to the UnRegister the file question.

RunWait('regsvr32 /u /s "' & $File, @SystemDir)

EndIf

EndIf

MsgBox(0, "Register/UnRegister", "Finished!",10) ;Tell the user that the script has completed.

WinMinimizeAllUndo ( ) ;Restore all windows to their original positions.

Exit ;Stop Execution.

Link to comment
Share on other sites

Gui Version...

;

; AutoIt Version: 3.1.1.0

; Language: English

; Platform: Win9x/NT

; Author: James Borak

;

; Script Function:

; Allow the user to Register or Unregister the file they specify.

#include <GuiConstants.au3>

WinMinimizeAll ( ) ;Minimize all the windows while this script executes.

;Title for the File Open dialog.

$message = "Choose the file you would like to Register or Unregister."

;Show the user the file open dialog.

;Options 1 = File Must Exist (if user types a filename), 2 = Path Must Exist (if user types a path).

$File = FileOpenDialog($message, @SystemDir & "\System32", "Components (*.dll;*.ocx)", 1 + 2 )

;If there were any errors or the user did not choose a file then get out.

If @error Then

#Region --- CodeWizard generated code Start ---

Dim $iMsgBoxAnswer

$iMsgBoxAnswer = MsgBox(48,"SWG - Register/UnRegister","No File was chosen - Exiting",2)

Select

Case $iMsgBoxAnswer = -1 ;Timeout

Case Else ;OK

EndSelect

#EndRegion --- CodeWizard generated code End ---

WinMinimizeAllUndo ( ) ;Restore all windows to their original positions.

Exit ;Stop Execution.

EndIf

;Create the GUI

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("SWG - Register/UnRegister", 592, 316,(@DesktopWidth-592)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Button1 = GuiCtrlCreateButton("Register: " & $File, 20, 10, 550, 50)

$Button2 = GuiCtrlCreateButton("UnRegister: " & $File, 20, 70, 550, 50)

$Label_3 = GuiCtrlCreateLabel("", 30, 140, 550, 20)

$Button4 = GuiCtrlCreateButton("Select Another File", 20, 180, 550, 50)

$Button5 = GuiCtrlCreateButton("Exit", 20, 250, 550, 50)

;Run the GUI until it is closed

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE ;The user pressed the X in the top right corner...get out.

ExitLoop

Case $msg = $Button1 ;When button1 is pressed, the file is registered

RunWait('regsvr32 /s "' & $File, @SystemDir)

GuiCtrlSetData($Label_3, $File & " has been Registered")

Case $msg = $Button2 ;When button2 is pressed, the file is unregistered

RunWait('regsvr32 /u /s "' & $File, @SystemDir)

GuiCtrlSetData($Label_3, $File & " has been UnRegistered")

Case $msg = $button4 ;The user pressed the Select Another File button.

GUISetState (@SW_HIDE) ;Hide the GUI

$File = FileOpenDialog($message, @SystemDir & "\System32", "Components (*.dll;*.ocx)", 1 + 2 )

If @error Then ;If there were any errors or the user did not choose a file then get out.

#Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Warning, Timeout=5 ss

Dim $iMsgBoxAnswer

$iMsgBoxAnswer = MsgBox(48,"SWG - Register/UnRegister","No File was chosen - Exiting",2)

Select

Case $iMsgBoxAnswer = -1 ;Timeout

Case Else ;OK

EndSelect

#EndRegion --- CodeWizard generated code End ---

ExitLoop

Else

GuiCtrlSetData($Button1, "Register: " & $File) ;Set the button labels and show the GUI

GuiCtrlSetData($Button2, "UnRegister: " & $File)

GUISetState (@SW_SHOW)

EndIf

Case $msg = $Button5 ;The user pressed the Exit button...get out.

GUISetState (@SW_HIDE) ;Hide the GUI

MsgBox(48,"SWG - Register/UnRegister","Goodbye ",1)

ExitLoop

EndSelect

WEnd

WinMinimizeAllUndo ( ) ;Restore all windows to their original positions.

Exit ;Stop Execution.

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