Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3811

My Shell is timing out...?

$
0
0

I wanted to zip a folder using a shell command.
I started using a public domain tar.exe as a resource, but for some reason after having executed the command ‘successfully’, i would get a timeout response from the shell. So naturally I tried a different approach, thinking my resource was the issue.

So I dug around and found a thread on zip file creation but it would seem that thread is defunct… So I propose this solution. With the caveat that I am still getting a timeout from my shell!

P.S. I hate using chr(34) but haven’t mastered triple quoting… :wink:

Xojo 2019 R1.1

Public Shared Sub CompressFolder(myFolderToCompress as FolderItem, output as FolderItem)
  Dim sh As New Shell
  
  // Set the mode to synchronous
  sh.Mode = 0
  
  // Define the PowerShell command
  Dim psCommand As String
  psCommand = "powershell.exe -Command " + chr(34) + "Compress-Archive -Path '" + myFolderToCompress.ShellPath + "' -DestinationPath '" + output.ShellPath +"'" +chr(34)
  
  // Execute the command
  sh.Execute(psCommand)
  
  // Check for errors
  If sh.ErrorCode = 0 Then
    MsgBox("PowerShell command executed successfully.")
  Else
    MsgBox("Error executing PowerShell command: " + sh.Result)
  End If
End Sub

4 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 3811

Trending Articles