Xavier Posted September 6, 2005 Share Posted September 6, 2005 Hi all, I'm trying to run programs with a admin account, it works fine but the windows is visible. Here is part of the code Runasset ($AdminAccount, $DomainName, $AdminPassword) Run (@Comspec & " /c " & "dsquery " & $target & " -samid " & $Computername & "$" & " -limit 0 | dsget " & $target & " -memberof >> " & $CompInfoBuffer , "c:\temp", @SW_HIDE) Runasset() If i try the same without runasset, the windows won't appear Any help would be greatly apprecited. Xavier Link to comment Share on other sites More sharing options...
andd Posted September 6, 2005 Share Posted September 6, 2005 I don't know why the window isn't hide with the runasset(), but you can try to use the WinSetState() call to hide it when it appears... Link to comment Share on other sites More sharing options...
dabus Posted September 6, 2005 Share Posted September 6, 2005 Only works with *.exe-files (obviously) ; AutoIt Version: 3.0 ; Language: English ; Platform: Win9x/NT/XP ; Author: jos van der Zande ; AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("TrayIconHide", 1) Break(0) $USERNAME = "Administrator" $PASSWORD = "Secret" $RUN = 0 ; run indicator ; retrieve the cycle from commandline If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] If $RUN = 0 Then RunAsSet($USERNAME, @ComputerName, $PASSWORD) Run('"' & @ScriptFullPath & '" " 1"') If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode") Exit EndIf ; commands go here that require Administrator rights Link to comment Share on other sites More sharing options...
therks Posted September 6, 2005 Share Posted September 6, 2005 (edited) I asked this same question many moons ago... If I remember correctly, it's because of some built-in Windows security type thing that won't let you start a program running as a different user as hidden. My work around was to run the AutoIt script as another user, which of course has no window by default, and then have the script do a regular Run() call to run the program. Something like this (this example needs to be compiled, but there are ways you can do it without compiling): If $CmdLine[0] < 1 Then RunAsSet('USERNAME', @ComputerName, 'ASSWORD') Run(@AutoItExe & ' /runasset') ElseIf $CmdLine[1] = '/runasset' Then Run('C:\Program.exe') EndIf *Edit: Looks like someone beat me to it. Edited September 6, 2005 by Saunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Xavier Posted September 6, 2005 Author Share Posted September 6, 2005 Well, thank you all Xavier 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