24 posts in this topic
Hi all. I am creating an app that runs a program with the admin privileges using the shellexecute's run as verb, but what my problem is, that no matter what I use to launch the program, it doesn't quite work like the run dialog would (certain programs don't get found, etc.). I've tried using the explorer.exe and passing the program to it, that is unreliable and opens documents folder sometimes instead, I've tried using the @comspec /c and that works better, but still some of the programs aren't being found that would be with the run dialog e.g., if I do @comspec /c diskpart it won't find it, I've even tried setting the working dir, but still no luck. I also tried passing commandline params to C:\WINDOWS\system32\rundll32.exe shell32.dll,#61, but no luck. can anyone help me what way to go in order to be able to launch programs in the run dialog style? is there a function in winapi that run dialog uses that I could use as well? Or what would be the best way to go about this? Any help much appreciated.
I need help.
I have a project that outputs reports to PDF using @mLipok's lovely QuickPDF. The PDF is created with no problem and I am sure the problem is not there.
However, I then have to open the PDF so the user can see it.
I use (a) short file name and (b) object properties
$oQP.SetPageLayout(2) $oQP.SetPageMode(3) ... $sFilename ; as created by UDF Local $sShortname = FileGetShortname( sFilename , 1 ) Run( @ComSpec & " /c start /max " & sShortname, "", @SW_HIDE ) ; force default PDF reader to open PDF maximized Then the RUN should open it with the default application.
I have tested extensively on 32 bit Win7 and 64 bit Win10. Works.
However, 64 bit Win8 and another Win7 laptop gives a problem.
The problem is this: when (typically) Adobe Reader is ALREADY open, the PDF opens almost instantaneously. If the Reader is not open, it seems to stall. Never opens.
The host on which the report will be opened is unknown to me and the PDF reader can not be hard coded.
Right now, my only brutal, very un-stylish solution is to force the Reader open prior to the RUN command.
Any ideas or advice on what causes this or how it could be remedied would be greatly appreciated.
Trying to automate the sideload of a Windows Store app via .ps1 script...
RunWait(@ComSpec & ' /c' & 'C:\"WB Resources"\APP_Prod\Add-AppDevPackage.ps1') Above doesn't work... I assume this is trying to open in CMD.
Normally we right click the .ps1 and open with powershell, then we have to type "A" to start the install, it installs and then type any yet to exit.
However I cant get the powershell to even open.
Kind of puzzled here, any suggestions would be a help.
PS I also tried to convert the .ps1 to exe, but that was a huge failure... lol
I have a problem, I cant run script as administrator in Windows 10:
Global $sUserName = "administrator"
Global $sPassword = "pass"
Global $sDomain = "domain"
RunAsWait($sUserName, $sDomain, $sPassword, 2, "main.exe", "", @TempDir)
If I run "run.exe" it dont work...
If I change main.exe to this:
and it runs and shows administrator in message box... but it cant elevate main.exe with RegWrite() command...
I tried using #RequireAdmin in first line of main.exe, but it not worked... UAC is set to "do not notify"
This method of elevation worked on Windows 7 and Windows XP...
I've been using this UDF to set ACL permissions to some network folders, everything works great (no issues). However, I want to apply these permissions using elevated domain credentials supplied by the user and not the user that's currently running the script. As a temporary solution, I've implemented a RunAs function, but that's not the solution I'm looking for. I'm not fluent with using Dlls, but I have been trying out different methods.
My RunAs Function:
Func _RunAs($sUser, $sPass) If @Compiled Then RunAs($sUser, @LogonDomain, $sPass, 4, FileGetShortName(@ScriptFullPath), "", @SW_MAXIMIZE) Else RunAs($sUser, @LogonDomain, $sPass, 4, FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath), "", @SW_MAXIMIZE) EndIf EndFunc ;==>_RunAs I tried LogonUser and I know that I can take that token to ImpersonateLoggedOnUser, but I'm not sure how to implement that or if that's even the right method. I also need to RevertToSelf once completed.
Func _LogonUser($sUsername, $sPassword, $sServer = @LogonDomain) ; Returns True if user exists Local $stToken $stToken = DllStructCreate("int") Local $aRet = DllCall("advapi32.dll", "int", "LogonUser", _ "str", $sUsername, "str", $sServer, "str", $sPassword, "dword", 3, "dword", 0, "ptr", DllStructGetPtr($stToken)) ;$hToken = DllStructGetData($stToken, 1) If Not @error And $aRet <> 0 Then Return True EndIf Return False EndFunc ;==>_LogonUser Any assistance, suggestions or idea's would be helpful.