Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
lylererger
Creator II
Creator 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
vikasmahajan

https://community.qlik.com/thread/196972

See my reply

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.