Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
lylererger
Contributor II

EXECUTE PowerShell with Administrator Rights

Hi friends

Is that possible at all?

Look.

I'm trying:

1. Run QV app with the next script:

LET vtmpFile = 'C:\Users\ADMIN\Desktop\PowerShell Runs VBA Sub\RunVBASub.ps1';

EXECUTE powershell.exe /C /Q $(vtmpFile);

2. I wrote the Power Shell commandlets to run Excel's VBA macros:

Set-ExecutionPolicy Unrestricted

$excel = new-object -comobject excel.application

$strFileName = "C:\Users\ADMIN\Desktop\PowerShell Runs VBA Sub\TEST.xlsm"

$excelFiles = Get-ChildItem -Path($strFileName)

$app = $excel.Application

$workbook = $app.workbooks.open($excelfiles)

$app.Visible = $False

$excel.displayalerts = $False

$workbook.Activate()

$app.Run("CreateTXT")

$tmpFileName = "C:\Users\ADMIN\Desktop\PowerShell Runs VBA Sub\tmpTEST.xlsm"

$workbook.saveas($tmpFileName)

$workbook.close()

$excel.quit()

If (Test-Path $strFileName){

  Remove-Item $strFileName

}

Rename-Item $tmpFileName $strFileName

3. VBA macros saving text file into folder:

Sub CreateTXT()

    strFile_Path = "C:\Users\ADMIN\Desktop\PowerShell Runs VBA Sub\Check.txt"

   

    Open strFile_Path For Output As #1

    Print #1, "CheckMask"

    Close #1

End Sub

Question:

How give to qv administrator right's to run powershell commandlets. Because if i'm running powershell script as administrator - everything works fine. But when i trying run the power shell script from qv using "EXECUTE" statement - it is not works. Please Help me to do that.

Thanks in advance.

P.S: All sources in attachment

1 Reply
Highlighted
vikasmahajan
Esteemed Contributor

Re: EXECUTE PowerShell with Administrator Rights