Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
TheEffect
Aug 12, 2013
I think this is the correct thread... Total newbie at VB.

Anyway, I'm creating a GUI in order to launch a batch file which then kicks off a PowerShell script. The GUI compiles fine and everything works great, however when I go to deploy the file it doesn't actually include any of the supporting files like the batch scrips or PowerShell scripts and their directories.

Stupid question but... how do I make sure these are included with the project when a user goes to install it? Using Visual Studio Express 2013.

Edit- Does it make it more complicated if there are directories that the PS script replies on in order to write out logs to? All my real coding is in the scripts. The form is just a user-friendly GUI.

TheEffect fucked around with this message at 20:48 on Jul 23, 2014

Adbot
ADBOT LOVES YOU

TheEffect
Aug 12, 2013

Mr Shiny Pants posted:

You should create the folders within VS solution and tell it to copy the solution files "always". The copy option is within the file properties of the file you want it to copy.

I see. Do I need to create the empty directories (that get populated at run-time) myself? It seems I can't add an entire directory at once.

When it's installed I'm guessing these files/directories will go into the "Publishing Folder Location"(is there something better to use than "C:\Program Files (x86)\" here?), correct?

Edit- Hmm, nope. That doesn't appear to work. I don't see that the files are being copied over to the installation directory. The buttons on my form use direct paths to the scripts to launch them so I'm not sure if that makes any difference with how I need to go about this.

TheEffect fucked around with this message at 21:22 on Jul 23, 2014

TheEffect
Aug 12, 2013

GrumpyDoctor posted:

How are you deploying?

I'm just trying to make it as easy as possible to deploy this to other users who are not very PC savvy. I'm clicking "Build" -> "Publish [project]". I don't need an installer per-say. The one-click install process that this is creating is fine for my purposes; I'm just not sure how to get the files that the form relies on to copy over to the installation directory when it does get installed.

Edit- I think I found it. I had to set "Build Action" to "Content" on my files (why can't I do this per directory?). Still testing...

Editx2- The copies are being copied over just fine now, but not the empty directories. When I try to add the empty directory to my solution it tells me the folder already exists, but it's not in my solution explorer?

TheEffect fucked around with this message at 22:24 on Jul 23, 2014

TheEffect
Aug 12, 2013

Che Delilas posted:

Edit: Okay, reading back I see that the scripts need these folders, not your application. In that case your application should probably check for the folders on startup instead of every access. Or if you have access to the underlying script, make the script do it (why isn't the script doing it).

You're right. I'll add some logic in the script to check for the folders I need and create them if needed.

I didn't design the script with a GUI in mind. Once my boss saw it he wanted it to be implemented globally in an easy manner, so I brushed off my intro to VB book and started going at it in a backwards way, hence why I'm finding it so difficult and trying to find work-arounds to get this thing going like I want it to.

Thanks for the help everyone!

TheEffect
Aug 12, 2013
Can I use a wildcard to search for directories that start with a certain string? Pseudo-code example-

If *DirExists*("C:\Program Files\ABC" & *Wildcard here* & ".txt") Then
*Do something*

TheEffect
Aug 12, 2013

Excellent, thank you!

TheEffect
Aug 12, 2013
I was just wondering if the following was possible with VB.Net-

I want to make an application that automatically names a group chat via Lync. Currently the way we do it (because we don't use Lync's persistent chat feature) is create a word document with the title of the Lync chat we want, open it open and click "Share" and then share by IM. Then you add people and when you start the conversation the title of the document is the title of the conference.

I know PS can obtain quite a bit of Lync data and do all sorts of things with it but I need this to be useable by employees who have limited rights, so assigning execution policy as unsigned wouldn't be possible for them to do, thus PS is out of the question... but can this be accomplished with VB.Net?

TheEffect
Aug 12, 2013

chippy posted:

I'm afraid I don't know the answer to your specific question but this looks to be a good starting point:

https://msdn.microsoft.com/en-us/library/office/hh243703(v=office.14).aspx
https://msdn.microsoft.com/en-us/library/office/hh243697(v=office.14).aspx

edit: Looks like you would want to use the ConversationManager to get the Conversation that interests you, and then you can set the title via its 'Properties' Property dictionary, one of which is 'Subject', which I'm guessing is probably the title you want.

https://msdn.microsoft.com/en-us/li...office.14).aspx

Sorry, should've specified this was Lync 2013, but I looked around for that documentation and think I found the 2013 versions of the articles you linked, so thank you! I should really utilize MSDN more often.

TheEffect
Aug 12, 2013

EssOEss posted:

Why don't you just sign your scripts so everyone can run them, if you think it can be done via PowerShell?

Because I don't control the certificate server for my org unfortunately.

TheEffect
Aug 12, 2013
I'm trying to rewrite a program that I wrote in PowerShell that copies files and folders over a network to a selected list of PCs. I've come across a snag though...

I'm using "directoryBrowse.ShowDialog()" for users to select a directory... but it obviously doesn't let them select individual files. Is there anything I can use that will allow my users to select either a file OR a folder to copy?

TheEffect
Aug 12, 2013

crashdome posted:

Oh man, I remembered this from way back and I had to google a little but, I think I found the solution. I simply remembered that it was configurable options of the OpenFileDialog control and this person seems to have documented them:
http://www.codeproject.com/Articles/44914/Select-file-or-folder-from-the-same-dialog

Apologies if it doesn't work the way you intended.

You're my savior man. Thanks!

TheEffect
Aug 12, 2013
Can I use File.Copy to copy directories, or should I be looking at something else? I noticed it says the destination source can't be a directory, but I can work past that,

Maybe a better way to ask this is- my application lets users select either files or directories and the plan is to then copy said selected files/directories to user-specified locations. Is File.Copy what I should be using?

TheEffect fucked around with this message at 23:58 on Mar 19, 2015

TheEffect
Aug 12, 2013
The FileSystem method is exactly what I needed. Thank you sir!

TheEffect
Aug 12, 2013
I'm trying to create a tray icon for my little home brewed application. Based on the code I have below, can anyone help me with the following-

1) The icon will stay after the program has quit until you hover over it. This can create multiple "ghost" icons. How do I prevent this?
2) A lot of the time click on the menu item, even though its clearly highlighted, won't do anything at all. What's the deal with that?
3) Each time the context menu opens up a taskbar icon is opened as well. How do I stop this?!?!
4) I have code that closes the context window after the mouse hovers away from it, but I'd rather it be so the user has to click to make it close. I can't find any examples that have worked for me thus far.

Here's the code-

code:
    Private Sub trayIcon_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles trayIcon.Click
        contextMenuNFC.AutoClose = True
        If e.Button = Windows.Forms.MouseButtons.Right Then
            contextMenuNFC.Show()
        End If
    End Sub

    Private Sub ContextMenuNFC_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles contextMenuNFC.Opening
        contextMenuNFC.Show(Cursor.Position)
        contextMenuNFC.Left = contextMenuNFC.Left + 1
        contextMenuNFC.Top = contextMenuNFC.Top + 1
    End Sub

    Private Sub ContextMenuNFC_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles contextMenuNFC.MouseLeave
        contextMenuNFC.Close()
    End Sub

    Private Sub ToolStripMenuItemHelp_MouseUp(sender As Object, e As MouseEventArgs) Handles ToolStripMenuItemHelp.MouseUp
        Process.Start("notepad.exe", resourcesDir + "\Documentation\" & "ReadMe.txt")
    End Sub

    Private Sub ToolStripMenuItemQuit_MouseUp(sender As Object, e As MouseEventArgs) Handles ToolStripMenuItemQuit.MouseUp
        Me.Close()
    End Sub
Essentially what I'm asking is how do I make this way less crappy than it is?

TheEffect fucked around with this message at 07:43 on Mar 23, 2015

TheEffect
Aug 12, 2013
Newbie question here, but how come this won't work for me?

code:
If (((pushFileSelectCheckBox1.Enabled = True) & (pushFileSelectCheckBox2.Enabled = True) & 
(pushFileSelectCheckBox3.Enabled = True) & (pushFileSelectCheckBox4.Enabled = True)) = True) Then
I get a runtime error saying that "True,False,False,False" can't be converted to type Boolean, but I thought what I was doing there is seeing if they are all true, and if so, the whole if statement would be true?

I've been reading up on the solution/ links posted here but can't seem to get it to work no matter what I do.

tunah posted:

Remember to call Dispose on the icon when your application is exiting.

Actually, I'm already calling it before the exit button is clicked. Should it be elsewhere?

code:
    Private Sub exitBTN_Click(sender As Object, e As EventArgs) Handles exitBTN.Click
        LogOutput(DateStamp() + " " + TimeStamp() + ": - Terminating Application.")
        trayIcon.Dispose()
        Me.Close()
    End Sub
Edit- Broke tables.


VVV That looks amazing! VVV

TheEffect fucked around with this message at 16:38 on Mar 25, 2015

TheEffect
Aug 12, 2013

GrumpyDoctor posted:

& is a string concatenation operator in VB.NET. Did you mean to use AndAlso?

I have no formal VB.Net training, only C++ and very little at that. That was exactly what was needed. Thank you!!!

TheEffect
Aug 12, 2013
I'm kind of a "try it and break it until you figure it out" kind of guy. So far I'm almost nearly done with writing a fairly impressive, in my opinion, file push / file remove program that let's user's choose a file or a directory to push/remove and let's them specify where it should go, without any training in vb.net at all. I guess that's elementary for most of you guys but I'm kind of proud of myself. Although to be fair I should've Google'd around a bit more on that last question since the answer was so very simple, and an intro tutorial probably WOULD'VE covered something like that.

Edit- So on that note, for a slightly more advanced question, how come "My.Computer.FileSystem.CopyDirectory" doesn't copy the directory that's selected like MSDN implies, but rather the CONTENTS of said directory? How can I get around this?

TheEffect fucked around with this message at 00:49 on Mar 26, 2015

TheEffect
Aug 12, 2013
So CopyDirectory doesn't do much really, like copying permissions over and things like that. I've found ways around most of these problems thanks to you guys but is there any way to copy the source folder's icon over? Or rather, whatever attribute handles the location of which icon to use for the directory?

TheEffect
Aug 12, 2013

chmods please posted:

I believe that's handled with desktop.ini inside the directory. I think it's hidden and possibly even system by default.

Hmm. Here's what's in my Desktop.ini-
code:
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21769
IconResource=%SystemRoot%\system32\imageres.dll,-183
[LocalizedFileNames]
Remote Desktop Connection.lnk=@%SystemRoot%\system32\mstsc.exe,-4000
If I make a change to an icon of a folder the .ini doesn't appear to change. Looks like it might have something to do with that "IconResource" variable(?) though.

How come I can push files that retain the chosen icon but not directories? :smith:

TheEffect
Aug 12, 2013
Am I overlooking something or is there not an easy way to put a click-able e-mail address in an RTF text box? Here's a bunch of pieced-together code that I found online when researching the issue. I had to convert most of it to VB from C# and then tweak it along the way. When I run my program I eventually get an out of memory exception at "thread.Start(threadData)".

code:
Public Interface IMarkupConverter
    Function ConvertXamlToHtml(xamlText As String) As String
    Function ConvertHtmlToXaml(htmlText As String) As String
    Function ConvertRtfToHtml(rtfText As String) As String
End Interface

Public Class MarkupConverter
    Implements IMarkupConverter

    Public Function ConvertXamlToHtml(xamlText As String) As String Implements IMarkupConverter.ConvertXamlToHtml
        Return ConvertXamlToHtml(xamlText)
    End Function
    Public Function ConvertHtmlToXaml(htmlText As String) As String Implements IMarkupConverter.ConvertHtmlToXaml
        Return ConvertHtmlToXaml(htmlText)
    End Function
    Public Function ConvertRtfToHtml(rtfText As String) As String Implements IMarkupConverter.ConvertRtfToHtml
        Return ConvertRtfToHtml(rtfText)
    End Function
End Class

Public Class Converter
    Public Shared Function ConvertRtfToHtml(rtfText As String) As String
        Dim thread = New Thread(AddressOf ConvertRtfInSTAThread)
        Dim threadData = New ConvertRtfThreadData With {.RtfText = rtfText}
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start(threadData)
        thread.Join()
        Return threadData.HtmlText
    End Function

    Public Shared Sub ConvertRtfInSTAThread(rtf As Object)
        Dim threadData = TryCast(rtf, ConvertRtfThreadData)
        threadData.HtmlText = ConvertRtfToHtml(threadData.RtfText)
    End Sub

    Private Class ConvertRtfThreadData
        Public Property RtfText() As String
            Get
                Return m_RtfText
            End Get
            Set(value As String)
                m_RtfText = value
            End Set
        End Property
        Private m_RtfText As String
        Public Property HtmlText() As String
            Get
                Return m_HtmlText
            End Get
            Set(value As String)
                m_HtmlText = value
            End Set
        End Property
        Private m_HtmlText As String
    End Class
End Class
And here's where I call it from Application Events on startup-

code:
NetworkFileController.Converter.ConvertRtfToHtml(NetworkFileController.mainForm.appInfoBox.Text)
All I want to be able to do is have my e-mail address click-able in a rich text box. I have a feeling I'm wasting a lot of time over-complicating things.

Edit- Was following the advice located here- http://stackoverflow.com/questions/28864778/sending-email-as-html-from-richtext-box

TheEffect fucked around with this message at 23:56 on Apr 11, 2015

Adbot
ADBOT LOVES YOU

TheEffect
Aug 12, 2013

ljw1004 posted:

That said, I don't know what that code is doing nor why. Whenever I wanted a hyperlink in win32, I made basically just made it a TextBlock, set font to blue underline, set its cursor to a Hand, and added a Click hander.

I like this much better. Thanks@

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply