Feb 28, 2015 11:00 PM
(This post was last modified: Mar 1, 2015 11:20 PM by Moon Rock.)
I need some help as I don't know how to go about running this shell as admin.
Code Shell(System.AppDomain.CurrentDomain.BaseDirectory() & "res.exe -extract " & otherfile & "," & resfile & ",VERSIONINFO,,")
Shell(System.AppDomain.CurrentDomain.BaseDirectory() & "res.exe -delete " & mainfile & "," & System.AppDomain.CurrentDomain.BaseDirectory() + "res.exe" & ",VERSIONINFO,,")
Shell(System.AppDomain.CurrentDomain.BaseDirectory() & "res.exe -addoverwrite " & mainfile & "," & mainfile & "," & resfile & ",VERSIONINFO,1,")
I know most of you guys have seen this, but I need to run res.exe as admin otherwise I get an error that access is denied. Huge thanks for helping me guys 🙂
DO NOT DEAL WITH THIS MEMBER
^^^ What in the hell?
And did you try using: "runas /user:<localmachinename>\administrator cmd"
That's off of the link Only3 provided.
Code Dim P As New Process
P.StartInfo.FileName = "res"
P.StartInfo.Verb = "runas"
P.StartInfo.Arguments = "-extract ..."
P.StartInfo.CreateNoWindow = True
P.StartInfo.UseShellExecute = True
P.Start()
I tried everything you guys mentioned and nothing worked, I either get the error or nothing happens. Still need help :3
if u want help u need to show us ur code
Edit - this should work
Code Dim P As New Process
P.StartInfo.FileName = "res"
P.StartInfo.Verb = "runas"
P.StartInfo.Arguments = "/c -extract ..."
P.StartInfo.CreateNoWindow = True
P.StartInfo.UseShellExecute = True
P.Start()
(Mar 2, 2015 04:59 AM)Only3 Wrote: if u want help u need to show us ur code
Edit - this should work
Code Dim P As New Process
P.StartInfo.FileName = "res"
P.StartInfo.Verb = "runas"
P.StartInfo.Arguments = "/c -extract ..."
P.StartInfo.CreateNoWindow = True
P.StartInfo.UseShellExecute = True
P.Start()
Still got the error after trying that, same error. It also showed the UI of res.exe
Code (typical assembly changer)
Code If File.Exists(Application.StartupPath & "\res.exe") Then
File.Delete(Application.StartupPath & "\res.exe")
End If
If File.Exists(Application.StartupPath & "\assemblychange.res") Then
File.Delete(Application.StartupPath & "\assemblychange.res")
End If
System.IO.File.WriteAllBytes(Application.StartupPath & "\res.exe", My.Resources.Res)
Dim source As String = My.Resources.String1
If File.Exists(Application.StartupPath & "\assemblychange.exe") Then
File.Delete(Application.StartupPath & "\assemblychange.exe")
End If
Dim Version = New Collections.Generic.Dictionary(Of String, String) : Version.Add("CompilerVersion", "v2.0")
Dim Compiler As VBCodeProvider = New VBCodeProvider(Version)
Dim cResults As CompilerResults
Dim Settings As New CompilerParameters()
With Settings
.GenerateExecutable = True
.OutputAssembly = Application.StartupPath & "\assemblychange.exe"
.CompilerOptions = "/target:winexe"
.ReferencedAssemblies.Add("System.dll")
.ReferencedAssemblies.Add("System.Windows.Forms.dll")
.MainClass = "X"
End With
source = source.Replace("*Title*", TextBox2.Text)
source = source.Replace("*Description*", TextBox3.Text)
source = source.Replace("*Company*", TextBox4.Text)
source = source.Replace("*Product*", TextBox5.Text)
source = source.Replace("*Copyright*", TextBox6.Text)
source = source.Replace("*Trademark*", TextBox7.Text)
source = source.Replace("*version*", NumericUpDown1.Value.ToString & "." & NumericUpDown2.Value.ToString & "." & NumericUpDown3.Value.ToString & "." & NumericUpDown4.Value.ToString)
source = source.Replace("*fversion*", NumericUpDown5.Value.ToString & "." & NumericUpDown6.Value.ToString & "." & NumericUpDown7.Value.ToString & "." & NumericUpDown8.Value.ToString)
cResults = Compiler.CompileAssemblyFromSource(Settings, source)
If cResults.Errors.Count > 0 Then
For Each CompilerError In cResults.Errors
MessageBox.Show("Error: " & CompilerError.ErrorText, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
Next
If File.Exists(Application.StartupPath & "\res.exe") = True Then
File.Delete(Application.StartupPath & "\res.exe")
End If
If File.Exists(Application.StartupPath & "\res.log") = True Then
File.Delete(Application.StartupPath & "\res.log")
End If
If File.Exists(Application.StartupPath & "\res.ini") = True Then
File.Delete(Application.StartupPath & "\res.ini")
End If
If File.Exists(Application.StartupPath & "\assemblychange.exe") Then
File.Delete(Application.StartupPath & "\assemblychange.exe")
End If
If File.Exists(Application.StartupPath & "\assemblychange.res") Then
File.Delete(Application.StartupPath & "\assemblychange.res")
End If
MessageBox.Show("An error occurred. The assembly was not changed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Dim otherfile As String = Application.StartupPath & "\assemblychange.exe"
Dim resfile As String = Application.StartupPath & "\assemblychange.res"
Dim mainfile As String = TextBox1.Text
Shell(System.AppDomain.CurrentDomain.BaseDirectory() & "res.exe -extract " & otherfile & "," & resfile & ",VERSIONINFO,,")
Shell(System.AppDomain.CurrentDomain.BaseDirectory() & "res.exe -delete " & mainfile & "," & System.AppDomain.CurrentDomain.BaseDirectory() + "res.exe" & ",VERSIONINFO,,")
Shell(System.AppDomain.CurrentDomain.BaseDirectory() & "res.exe -addoverwrite " & mainfile & "," & mainfile & "," & resfile & ",VERSIONINFO,1,")
If File.Exists(Application.StartupPath & "\assemblychange.exe") Then
File.Delete(Application.StartupPath & "\assemblychange.exe")
End If
If File.Exists(Application.StartupPath & "\assemblychange.res") Then
File.Delete(Application.StartupPath & "\assemblychange.res")
End If
If File.Exists(Application.StartupPath & "\res.exe") = True Then
File.Delete(Application.StartupPath & "\res.exe")
End If
If File.Exists(Application.StartupPath & "\res.log") = True Then
File.Delete(Application.StartupPath & "\res.log")
End If
If File.Exists(Application.StartupPath & "\res.ini") = True Then
File.Delete(Application.StartupPath & "\res.ini")
End If
If Icon.Text = vbNullString Then
MsgBox("Icon Is Required <3")
Else
IconChanger.InjectIcon(mainfile, Icon.Text)
End If
MessageBox.Show("The assembly has been changed successfully.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Lmk if you want the whole project.
first dont see when u use my code
second u can change Application.StartupPath & "\res.exe" to "res.exe"
also why u use reshacker if u can do it with codedom
Mar 2, 2015 08:04 AM
(This post was last modified: Mar 2, 2015 08:05 AM by Moon Rock.)
(Mar 2, 2015 08:01 AM)Only3 Wrote: first dont see when u use my code
second u can change Application.StartupPath & "\res.exe" to "res.exe"
also why u use reshacker if u can do it with codedom
I removed it so you can have the original code.
Code Dim P As New Process
P.StartInfo.FileName = "res"
P.StartInfo.Verb = "runas"
P.StartInfo.Arguments = "/c -extract " & otherfile & "," & resfile & ",VERSIONINFO,,"
P.StartInfo.CreateNoWindow = True
P.StartInfo.UseShellExecute = True
P.Start()
P.StartInfo.Arguments = "/c -delete " & mainfile & "," & System.AppDomain.CurrentDomain.BaseDirectory() + "res.exe" & ",VERSIONINFO,,"
P.Start()
P.StartInfo.Arguments = "/c -addoverwrite " & mainfile & "," & mainfile & "," & resfile & ",VERSIONINFO,1,"
P.Start()
I just removed the "/" from "/res.exe"
I'm using reshacker because that's the only way I found to do it.
put res in ur app dir and test the code with one arg and see if its work
its much easy to change app versioninfo with codedom just search the section
Mar 2, 2015 08:14 AM
(This post was last modified: Mar 2, 2015 08:22 AM by Moon Rock.)
(Mar 2, 2015 08:08 AM)Only3 Wrote: put res in ur app dir and test the code with one arg and see if its work
its much easy to change app versioninfo with codedom just search the section
Don't think it's going to work because of
Code If File.Exists(Application.StartupPath & "\res.exe") Then
File.Delete(Application.StartupPath & "\res.exe")
End If
Just comment out?
It's put 3 times in the code.
Update
Just tried it and it's not changing the assembly, but I'm not getting an error. Also I can see the res.exe window.
(Mar 2, 2015 09:34 AM)Only3 Wrote: thats cuz u need the other args too
anyway use https://hackforums.net/showthread.php?tid=695204
Thanks for the link, I'll try it out once I get some time. I'll report back then.
|