Thread: Open Resource

Results 1 to 9 of 9
  1. #1
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine

    Open Resource

    I added a resource in my fb project and would like to open it but cant!!!
    tried this IO.File.WriteAllBytes(filePath, My.Resources.TheResourceHere)



  2. #2
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    Quote Originally Posted by ySoNoob View Post
    I added a resource in my fb project and would like to open it but cant!!!
    tried this IO.File.WriteAllBytes(filePath, My.Resources.TheResourceHere)
    I think I know the problem, but you're not telling us much.

    Does the file path consist of the file name w/ extension? You have to tell it in the first parameter of the exact file location to write to.
    Example: C:\Users\MPGH\Documents\TheResourceHere.dll

  3. The Following User Says Thank You to DawgiiStylz For This Useful Post:

    ySoNoob (04-28-2013)

  4. #3
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine
    Quote Originally Posted by DawgiiStylz View Post

    I think I know the problem, but you're not telling us much.

    Does the file path consist of the file name w/ extension? You have to tell it in the first parameter of the exact file location to write to.
    Example: C:\Users\MPGH\Documents\TheResourceHere.dll
    mmk ill try that I just tried the folder!

    ---------- Post added at 07:27 PM ---------- Previous post was at 06:58 PM ----------

    didn't help im trying to open a file (.exe) via Button!



  5. #4
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    Can't open if its in your resources

    You'll have to write the file to disk and then run that file
    Last edited by DawgiiStylz; 04-28-2013 at 05:43 PM.

  6. #5
    Pingo's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    687
    Reputation
    24
    Thanks
    865
    My Mood
    Blah
    @ySoNoob
    So you have this .exe in your resource and you want to write it to your hdd and run it?
    Something like
    Code:
    Imports System . I O
    Code:
        Sub RunResource(ByVal Name As String, ByVal _Resource As Byte())
            Dim _Path As String = Application.StartupPath + If(Name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase), Name, Name + ".exe")
            File.WriteAllBytes(_Path, _Resource)
            If File.Exists(_Path) Then
                Process.Start(_Path)
            End If
        End Sub
    And on your button
    Code:
    RunResource("TestMe", My.Resources.Name In Resource)

  7. The Following 2 Users Say Thank You to Pingo For This Useful Post:

    Matroix73 (05-03-2013),ySoNoob (04-28-2013)

  8. #6
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine
    OMG thx that worked!

    ---------- Post added at 07:56 PM ---------- Previous post was at 07:53 PM ----------

    /Solved @Jorndel



  9. #7
    Pingo's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    687
    Reputation
    24
    Thanks
    865
    My Mood
    Blah
    Since that was what you were after, maybe this will do you too.
    Just added to that other code.
    Code:
        Sub RunResource(ByVal Name As String, ByVal _Resource As Byte())
            Dim _Path As String = Path.GetTempPath() + If(Name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase), Name, Name + ".exe")
            File.WriteAllBytes(_Path, _Resource)
            If File.Exists(_Path) Then
                Process.Start(_Path)
            End If
            Dim pA As String = Path.GetTempPath() + Guid.NewGuid().ToString() + ".bat"
            Using s As StreamWriter = File.CreateText(pA)
                s.WriteLine(":Ret")
                s.WriteLine("Ping Localhost -n 3 > nul") 'Delay loop for a few seconds
                s.WriteLine("del " + Chr(34) + _Path + Chr(34))
                s.WriteLine("if exist " + Chr(34) + _Path + Chr(34) + " goto Ret")
                s.WriteLine("del " + Chr(34) + pA + Chr(34))
            End Using
            If File.Exists(pA) Then
                Dim Pr As ProcessStartInfo = New ProcessStartInfo(pA)
                Pr.WindowStyle = ProcessWindowStyle.Hidden
                Process.Start(Pr)
            End If
        End Sub
    That will create the .exe and a .bat file in the Temp folder and run them both.
    Once the .exe closes, the .bat will delete it and itself so you dont leave anything on your pc.

  10. The Following User Says Thank You to Pingo For This Useful Post:

    ySoNoob (04-29-2013)

  11. #8
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Code:
    Private Sub RunFromMemory(ByVal bytes As Byte())
      Dim assembly As Assembly = assembly.Load(bytes)
      Dim entryPoint As MethodInfo = [assembly].EntryPoint
      Dim objectValue As Object = RuntimeHelpers.GetObjectValue([assembly].CreateInstance(entryPoint.Name))
      entryPoint.Invoke(RuntimeHelpers.GetObjectValue(objectValue), New Object() {New String() {"1"}})
    End Sub
    
    Private Sub ButtonClick() Handles ButtonX.Click
      Dim x As New Threading.Thread(AddressOf RunFromMemory)
      x.Start(My.Resources.TheResourceHere)
    End Sub

  12. #9
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine
    thank you all! but idk about using that second code I might just stick to the first 1...because when I debugged it it ran rin then I closed what it opened then triyed to click it again and brung an error up ...Idk ill work with it! C WHAT I CAN DO! but thx for the codding help!



Similar Threads

  1. easy AoE1 resource hack
    By oowatsthat in forum Hack Requests
    Replies: 1
    Last Post: 05-02-2006, 09:13 PM
  2. Opening 5-8 Slots
    By ClapBangKiss in forum WarRock - International Hacks
    Replies: 28
    Last Post: 05-02-2006, 05:27 PM
  3. I cant open WPE
    By ValconGSX in forum WarRock - International Hacks
    Replies: 8
    Last Post: 01-17-2006, 05:10 PM