script doesn't work after packaging

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
bn2hunt
Posts: 101
Last visit: Mon Aug 02, 2021 12:04 pm

script doesn't work after packaging

Post by bn2hunt »

Product, version and build: version 5.2.129
32 or 64 bit version of product: 64bit
Operating system: windows 10 pro
32 or 64 bit OS: 64bit
PowerShell Version: 5.0 build 10586 revision 494

I have a single form project that works when I click the run button but once I package the script it stops working. Here is the subroutine that isn't working. Specifically the New-psdrive line isn't working. When I try to copy a file from that location in a different function I get an error drive copyfrom does not exist. I have tried to package it using several different options with no luck. It has to run 32bit since I am using SQL and I currently have the 32bit version of SQL loaded on the machines I am running this script on. I have the STA mode checked in the packager settings and have tried every version of V2 and V5 for the platform. I am using Embed a default manifest and run mode of current user. If you need a complete version of the script let me know and I will remove the server names and send it to you.
  1. $buttonBrowseFolder_Click={
  2.     #TODO: Place custom script here    
  3.     $errind = $false
  4.     $result = $folderbrowserdialog2.ShowDialog()
  5.     if ($result -eq 'OK')
  6.     {
  7.         $tb_detach_Folder.Text = $folderbrowserdialog2.SelectedPath
  8.         $cfrom = $folderbrowserdialog2.SelectedPath
  9.         if (Get-PSDrive -Name copyfrom -ea SilentlyContinue){Remove-PSDrive copyfrom}
  10.         new-psdrive -Name copyfrom -PSProvider filesystem -Root $cfrom
  11.     }
  12.     else
  13.     { }
  14.     $btn_copy.Enabled = $true
  15. }
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: script doesn't work after packaging

Post by DevinL »

Usually, when something like this occurs it's due to the executable not having the correct permissions. Can you provide the exact build settings you're using?

You can either type this all out or upload the .psbuild file that contains this information. If you don't want it to be public, you can zip it up and upload it here: https://www.sapien.com/support/upload
DevinL
SAPIEN Technologies, Inc.
User avatar
bn2hunt
Posts: 101
Last visit: Mon Aug 02, 2021 12:04 pm

Re: script doesn't work after packaging

Post by bn2hunt »

I had to zip the file, I got a invalid filetype when I tried to attach the psbuild file.
Attachments
attach_detach_proj.psproj.zip
(1022 Bytes) Downloaded 150 times
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: script doesn't work after packaging

Post by DevinL »

From what I can see, your settings shouldn't be an issue.

Can you try packaging with an elevated manifest? To do this go to your packager settings, Manifest Settings, and change the manifest type:
Default_Elevated_Manifest.png
Default_Elevated_Manifest.png (32.37 KiB) Viewed 3378 times
DevinL
SAPIEN Technologies, Inc.
User avatar
bn2hunt
Posts: 101
Last visit: Mon Aug 02, 2021 12:04 pm

Re: script doesn't work after packaging

Post by bn2hunt »

I changed it to use an elevated manifest and it didn't help. I am almost positive it worked before I upgraded to my current version but I couldn't tell you what version I was using before, I don't skip or miss many version updates.
User avatar
bn2hunt
Posts: 101
Last visit: Mon Aug 02, 2021 12:04 pm

Re: script doesn't work after packaging

Post by bn2hunt »

I got it working. For some reason once I packaged the script it was losing the new-psdrive information when I went to use it. I made the location a global variable and recreate the new-psdrive just before I want to use it and I am able to use that location. I don't understand why it changes after it is packaged but I am able to continue using the script now.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: script doesn't work after packaging

Post by DevinL »

Glad to hear you got it working.

If you have any further issues, please don't hesitate to post again.
DevinL
SAPIEN Technologies, Inc.
This topic is 7 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.