D4Rk5uMm0n3r Posted September 17, 2012 Share Posted September 17, 2012 Hello, I'm currently looking for some assistance I've been looking for sometime now.The code I'm currently unable to find requires to be able to use the "Run As Different User" to launch the application followed by being able to select the Current user Logged into the machine "Limited User" Via list. The concept is to allow the change to be applied sine the script being written is for the "Current User". This doesn't have to be fancy just trying to make lives easier. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 528, 308, 304, 124) $Button1 = GUICtrlCreateButton("Excel", 32, 32, 137, 33) $Button2 = GUICtrlCreateButton("Word", 32, 72, 139, 33) $Button3 = GUICtrlCreateButton("Outlook", 32, 112, 139, 33) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### _RenameRegKey("HKEY_CURRENT_USER\Software\SomeKey", "HKEY_CURRENT_USER\Software\ABCNew") ;Function _RenameRegKey ;returns 1 on success ; -1 if oldkey not found ; -2 if no change to make ; -3 if failed to create new key ; -4 failed to delete old key ;a backup of the old key is in the file $savereg ;a backup of new key is in $newreg Func _RenameRegKey($oldkey, $newkey, $savereg = Default, $newreg = Default) If $savereg = Default Then $savereg = @ScriptDir & '\back01.reg' If $newreg = Default Then $newreg = @ScriptDir & '\back02.reg' RegRead($oldkey, "") If @error = 1 Then Return -1;no such key If $oldkey == $newkey Then Return -2 Local $header, $all, $all1, $hf2 FileDelete($savereg) $proc = RunWait('regedit /e "' & $savereg & '" "' & $oldkey & '"'); /e to export $all = FileRead($savereg) If $all = "" Then Return -1;no data $all1 = StringReplace($all, $oldkey, $newkey) If @extended = 0 Then Return -2; no changes $hf2 = FileOpen($newreg, 2) FileWrite($hf2, $all1) FileClose($hf2) RunWait('regedit /s "' & $newreg & '"'); /s means silent, ie no prompt to write to the registry RegRead($newkey, "") If @error = 1 Then Return -3;failed EndIf If RegDelete($oldkey) = 2 Then Return -4 Return 1; ok EndFunc ;==>_RenameRegKey While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 FileMove(@AppDataDir & "\Microsoft\Office\Excel12.pip", @AppDataDir & "\Microsoft\Office\Excel12.pip.old") Call(_RenameRegKey("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel", "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel.old")) Case $Button2 FileMove(@AppDataDir & "\Microsoft\Office\Word12.pip", @AppDataDir & "\Microsoft\Office\Word12.pip.old") Call(_RenameRegKey("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word", "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word.old")) Case $Button3 FileMove(@AppDataDir & "\Microsoft\Office\MSOut12.pip", @AppDataDir & "\Microsoft\Office\MSOut12.pip.old") Call(_RenameRegKey("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook", "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook.old")) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now