Product, version and build: PowerShell 2015 4.2.99
32 or 64 bit version of product: 64
Operating system: Win7
32 or 64 bit OS: 64
Hi,
I am doing some test with your product regarding the creation of an EXE file from a powershell script.
On my script, I register to a WMI event so I need the script to be running at all times. At the present I use this command line:
powershell.exe -nofile -windowstyle hidden -file c:\temp\myscript.ps1
when using your packager module I dont see where I could introduce this powershell parameters. is it possible somehow?
Many thanks.
Jose
how to add -noexit parameter when using EXE packager
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: how to add -noexit parameter when using EXE packager
Since powershell.exe is not involved with a packaged executable, its command line parameters are not relevant.
A packaged executable never load a profile so that is easy.
If you do not want a command prompt, simply package with a Windows engine.
Maybe this will help:
https://www.sapien.com/blog/2014/03/25/ ... 14-part-1/
The title of this post implies that you want to specify -noexit, but that is contradicted by the windowsstyle hidden setting you ask for.
So I am not sure if this is something you need.
A packaged executable never load a profile so that is easy.
If you do not want a command prompt, simply package with a Windows engine.
Maybe this will help:
https://www.sapien.com/blog/2014/03/25/ ... 14-part-1/
The title of this post implies that you want to specify -noexit, but that is contradicted by the windowsstyle hidden setting you ask for.
So I am not sure if this is something you need.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: how to add -noexit parameter when using EXE packager
Hi alexander,
I think my question was not very clear, so better I attach a snippet of my code. Basically I register an action to the WMI event for storage USB devices. The function checks for the existence of a stamp file on the USB and do some other checks which are not included in the code.
I checked the PrimalScript options and I couldn't find any option to add "-noexit" or "hidden" behaviours in the executable...
sure that I am missing something but I don't know what.
Many thanks.
jose
I think my question was not very clear, so better I attach a snippet of my code. Basically I register an action to the WMI event for storage USB devices. The function checks for the existence of a stamp file on the USB and do some other checks which are not included in the code.
For this script to run as I expected, I need to execute it with the -noexit -windowstyle hidden options.$query = "SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveType=2"
Register-WmiEvent -Query $query -SourceIdentifier RemovableDiskDetection -Action {
$class = $eventArgs.NewEvent.__CLASS
$device = $eventArgs.NewEvent.TargetInstance.DeviceID
$wshell = New-Object -ComObject Wscript.Shell
switch($class)
{
__InstanceCreationEvent {
$path = $device + "\STAMP.kiosk"
Write-Host "*** Checking the existence of the file $path"
if(Test-Path -Path $path)
{
Write-Host "*** Looking for the content of the file $path"
$wshell.Popup("Inserted, device id: $device WITH STAMP.kiosk",0,"Done",0x1)
}
else{
$wshell.Popup("Inserted, device id: $device WITHOUT STAMP.kiosk",0,"Done",0x1)
}
}
__InstanceDeletionEvent {
$wshell.Popup("Removed, device id: $device ",0,"Done",0x1)
}
}
}
Basically if the powershell session is closed, the registration to the event is removed. In addition,I need the execution to be hidden in order to avoid the user be able to cancel it.powershell.exe -noexit -windowstyle hidden -file c:\temp\myscript.ps1
I checked the PrimalScript options and I couldn't find any option to add "-noexit" or "hidden" behaviours in the executable...
sure that I am missing something but I don't know what.
Many thanks.
jose