Sign in to follow this  
Followers 0
AppTux

ShellExecuteAs

18 posts in this topic

Is it possible to make or is there already a ShellExecuteAs function???

Thanks in advance, AppTux


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites



Might want to take alook at RunAs

Share this post


Link to post
Share on other sites

I already did that, but if I want to open the site (like www.autoitscript.com) it's impossible for RunAs.

I was thinking about a ShellExecuteAs() function made by myself. But that's really hard I think, but it's possible, but you need a lot of time to make such a good function as ShellExecute(). Maybe if I don't have anything else to do, can I try to make a ShellExecuteAs() but not now.... Not interested and I have other things to do. :)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

open the site (like www.autoitscript.com) it's impossible for RunAs.

did you try as using the URL as an argument to the browser you want to open it with?

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

That's possible, I also was thinking about that, but I'm working on a more advanced run for Windows, with functions like a logfile, abbreviations and search on the internet using search engines, so it's a bit more complicated than you suggested :)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

so it's a bit more complicated than you suggested explained :)


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

This might be a retarded way to do it, but assuming that ShellExecute inherits it's credentials from the calling script you may be able to do the following:

Create a function that uses RunAs to run another instance of itsself, passing a filename in the command line. (in quotes).

Then add a line to the top of your script that checks the command line when the script starts and ShellExecutes it if a file is specified, then exits.

This should allow you to run the script, as User1, which launches the same script as User2, but with an CmdLine argument, which then ShellExecutes a file as User2 and exits.

I'm having trouble explaining it clearly. I hope you understand.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

got it use runas with the value obtained from

HKEY_CURRENT_USER\Software\Classes\http\shell\open\command

if not found (current user) then read

HKEY_CLASSES_ROOT\http\shell\open\command

stringreplace "%1" with your url in quotes

This way the url will still be launched in its default browser.

[Edit-1] concidering you run it as a diffrent user you should probably just need HKEY_CLASSES_ROOT\http\shell\open\command

[Edit-2] check post below

Edited by Djarlo

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I think I got this Function from a Script by wakillon.

Func _GetDefaultBrowser()
    Local $sRegRead = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "")
    $sRegRead = StringRegExpReplace($sRegRead, '\A[^"]*"([^"]+)".*\Z', '\1')
    If FileExists($sRegRead) Then 
        Return $sRegRead
    EndIf
    Return SetError(1, 0, "")
EndFunc   ;==>_GetDefaultBrowser
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I think I got this Function from a Script by wakillon.

Func _GetDefaultBrowser()
    Local $gb_RegRead = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "")
    $gb_RegRead = StringRegExpReplace($gb_RegRead, '\A[^"]*"([^"]+)".*\Z', '\1')
    If FileExists($gb_RegRead) Then Return $gb_RegRead
    Return SetError(1, 0, 0)
EndFunc   ;==>_GetDefaultBrowser

I like how it checks if its a valid string and if the path exists.

i changed it a lil that after doing that check it returns it with the syntax specified in the registry instead of just the exe path :-)

$i = _GetDefaultBrowserString('http://google.com')
ConsoleWrite($i & @LF)

Func _GetDefaultBrowserString($url)
    Local $gb_RegRead = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "")
    Local $path = StringRegExpReplace($gb_RegRead, '\A[^"]*"([^"]+)".*\Z', '\1')
    If Not FileExists($path) Then Return SetError(1, 0, 0)
    $path = StringReplace($gb_RegRead, '%1', $url)
    If @extended = 0 Then Return SetError(2, 0, 0)
    Return $path
EndFunc   ;==>_GetDefaultBrowserString

returns in my case:

"D:\Program Files\Mozilla Firefox\firefox.exe" -requestPending -osint -url "http://google.com"

Share this post


Link to post
Share on other sites

Nice update Djarlo :)


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Thanks for all your replies, I'll try soon, but how about images or whatever, do I have to replace

Local $gb_RegRead = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "")

with this: ($extension is the extension of the file, like .au3, .png, .jpg, .bat)

Local $gb_RegRead = RegRead("HKEY_CLASSES_ROOT\" & $extension & "\shell\open\command", "")

Edit: edited syntax above

Edited by AppTux

PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

Did some research in the registry, and in the .png folder in the registry there isn't a shell subfolder, but:

  • OpenWithList
  • OpenWithProgIds
  • PersistentHandler
And in the OpenWithList folder are 2 subfolders called:

  • ois.exe
  • PictureViewer.exe
And in the folder OpenWithProgIds are 3 REG_NONE values, and 1 REG_SZ value.

REG_NONE keys:

  • Opera.image
  • pngfile
  • QuickTime.png
And these means to the same called folders in the HKEY_CLASSES_ROOT folder.

And in those is a folder named shell.

Now I have to find out where is written which one is used (Opera.image, pngfile or QuickTime.png). Anyone a idea?

P.S. : registry is so confusing... :)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

I'll try tomorrow, I don't have time today :)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

You can also use RunAs for urls like so:

Local $AdminAccount = 'YourAdmintratorAccount'
Local $Domain = 'YourDomain_or_ComputerName'
Local $Password = 'YourPassword'
Local $URL = 'http://www.google.com'

$Return = RunAs($AdminAccount, $Domain, $Password, 4, @Comspec & ' /c start ' & $URL, @SystemDir, @SW_HIDE)

MsgBox(262208, 'Result', $Return)
Edited by Varian

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