• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

DOS Commands In Visual Basic

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
How would I go about executing DOS commands in Visual Basic? My plan is to have an input field in VB, and then when the user pushes a button it will input this input into the DOS command and execute it.
 

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
Ok, update:

I have found that

Code:
  Dim sCommand As String
        sCommand = "DOSCOMMAND HERE"
        Shell("cmd.exe /c" & sCommand)

will execute a dos command, but lets say I want to echo from a text box inside VB? How would I go about that?

Code:
  Dim sCommand As String
        sCommand = "echo SOMETHINGFROMVB"
        Shell("cmd.exe /c" & sCommand)
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
I think that sCommand could be a filename with all the commands you want to execute in it.
Our do you want to be able to talk to the cmd process from individual lines of VB code?
 

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
I figured it out just now. Was very simple. Stuff box is a textbox btw.

Code:
Dim stuff As String

        stuff = stuffbox.Text

        Dim sCommand As String
        sCommand = "echo" & " " & stuff
        Shell("cmd.exe /c" & sCommand)
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
Thanks for letting us know how you got it working ! :toast:
I use this section as a programming reference quite often.
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
You should get in the habit of using System.Diagnostics.Process.Start() rather than Shell. Using that method, you can redirect StandardOutput, and StandardError. In your app, create a while loop to write the contents of each of those streams to a window in the application:

Code:
While p.StandardOutput.Peek() <> -1
  txt.Text +=p.StandardOutput.ReadLine()
End While
Repeat for StandardError.
 

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
Ok guys, here is where the work went to. A fun program to screw around with on the school network. Nobody knew what I meant when I said "use the command prompt to send messages," so I made my own program so people can talk over the network. Will improve later, want to add some more options, but for a quick time, this is good enough!

I took advantage of this original batch file written in about 30 seconds:

Code:
@echo off
color 1f
:begin
cls
set /p n=User: 
set /p m=Message: 
msg %n% %m%
pause
Goto begin

It only worked with Windows 7 / Vista, so in the VB code I added a condition to change between different versions of Windows. Anyway...

Enjoy!

Edit: For all those against opening strange .exe files they find on tech forums, this is for you:



http://www.virustotal.com/analisis/...ace159ac1db582d43e66605655427286e1-1264127325
 

Attachments

  • Easy Msg.exe
    49.5 KB · Views: 1,156
Last edited:
Joined
Nov 18, 2006
Messages
2,964 (0.47/day)
Location
your local vending machine
System Name HTPC||Lenovo IBM ThinkPad
Processor AMD Phenom II x4 965 stock 3.4GHz||Intel C2D T9300 @ 2.5GHz
Motherboard Zotac 890GX-ITX WiFi||Lenovo 8918CTO
Cooling Stock 3x 120's||Stock stuff
Memory 8GB (2x4GB) DDR3 6-6-6-15||3GB DDR2
Video Card(s) Asus 3870x2||nVidia Quadro NVS 140M
Storage 1TB Seagate Barracuda, 1x 2TB WD EARX ||Hitachi 160GB 7200RPM
Display(s) Samsung T260HD||
Case SilverStone Grandia GD05||
Audio Device(s) on-board||on-board
Power Supply Cooler Master 450W||6-cell
Software Windows 7 Pro x64||Windows 7 Pro x64/Linux Mint x64
That's a fun little program you got there.
This reminds me, I need to keep teaching myself how to code more in depth with VB.
 

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
It has been about 4 year since I touched VB! I forgot how much fun it was to write little programs like that!

ALSO: For those who care, the full code:

Code:
Public Class Form1

    Private Sub send_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles send.Click
        'Define and store user and message into strings
        Dim user As String
        Dim msg As String

        user = userbox.Text
        msg = msgbox.Text

        'Send all suicide mode!
        If checkall.Checked Then
            user = "*"
            userbox.ReadOnly = True

        End If

        'Main Code

        If radionew.Checked Then

            'Windows Vista / 7 Code
            'Calls the user and msg strings and inputs them into the DOS code to execute

            Dim sCommand As String
            sCommand = "msg" & " " & user & " " & msg
            Shell("cmd.exe /c" & sCommand)


        ElseIf radioold.Checked Then

            'Windows 2000 / XP Code
            'Calls the user and msg strings and inputs them into the DOS code to execute

            Dim sCommand As String
            sCommand = "net send" & " " & user & " " & msg
            Shell("cmd.exe /c" & sCommand)

        End If

    End Sub

    Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear.Click
        'Clears the message box
        msgbox.Text = ""
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Simple no?

If anyone is using Windows XP or 2000, please test the code for me! I have only 7 and Vista! Just make sure to check the correct box!

Download is here: http://forums.techpowerup.com/attachment.php?attachmentid=32339&d=1264124659
 
Last edited:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
You can use Environment.OSVersion to figure out what version of Windows the application is being run on is.

Code:
If Environment.OSVersion.MajorVersion >= 6
 ' Vista/7/Server 2008
Else
 ' XP/Server 2003/2000/NT


It does not work on Server 2003 most likely because "net send" is a Windows 2000 and older command. "msg" works fine:

Code:
msg Administrator test

I'll check XP but I'm pretty sure it will be the same result.


Edit: XP is the same as Server 2003 (use "msg").


If you change it over to use Process.Start, the command window, and most likely response, will appear in your application (or not at all) rather than separate windows.
 
Last edited:

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
You can use Environment.OSVersion to figure out what version of Windows the application is being run on is.

Code:
If Environment.OSVersion.MajorVersion >= 6
 ' Vista/7/Server 2008
Else
 ' XP/Server 2003/2000/NT


It does not work on Server 2003 most likely because "net send" is a Windows 2000 and older command. "msg" works fine:

Code:
msg Administrator test

I'll check XP but I'm pretty sure it will be the same result.


Edit: XP is the same as Server 2003 (use "msg").


If you change it over to use Process.Start, the command window, and most likely response, will appear in your application (or not at all) rather than separate windows.

So I need to change it so XP uses the msg command as well? Last time I checked, the net send command also worked on XP.

Also, the auto environment detector, GENIUS! I will use that!

EDIT: Hmm... trying to figure out how to "capture" the return text, is it possible to grab it and have that other window never open?
 
Last edited:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
"net send Administrator test" does not work on Server 2003. It says "the message alias could not be found on the network."


Come to think of it, the response Window will pop up even if you redirect output because the application recieveing the message most likely isn't the computer running the app. You can get rid of console windows though:

Code:
Imports System.Diagnostics

...

Dim psi As New ProcessStartInfo()
With psi
  .Arguments = user & " " & msg
  .CreateNoWindow = True
  .FileName = Environment.GetEnvironmentVariable("SYSTEMROOT") & "\system32\msg.exe"
  .UseShellExecute = False
  .ErrorDialog = False
  .RedirectStandardOutput = True
  .RedirectStandardError = True
  .WorkingDirectory = Environment.GetEnvironmentVariable("SYSTEMROOT") & "\system32"
End With

Dim p As New Process()
With p
  .StartInfo = psi;
  .Start();
  .WaitForExit();
End With

After that last End With is where you would put the While loop to handle the streams. I really see no need to in this case, however.


I don't have Visual Studio installed at this time so the code above is untested (converted to VB from C#).
 

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
New version... Really minor changes, removed an unneeded line of code, updated the icon, picture, etc. Added 90% transparency, and most of all, fixed the XP error. Next up is to make a "test" button that sends the local user a test message to make sure everything is correctly configured.

Edit: Please give suggestions for features if you think this small app needs improvement.
 

Attachments

  • Easy Msg.exe
    49.5 KB · Views: 788

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
By the way, all the version numbers are on here:
http://en.wikipedia.org/wiki/History_of_Microsoft_Windows#Product_progression

I don't know if Windows 2000 has msg.exe or not. Doing some Googling, it appears that Windows 2000 has msg.exe but some distros of Windows Vista does not (Home Basic and Home Premium).

In any case, you should add a check for the file before attempting to execute it:
Code:
If System.IO.File.Exists(Environment.GetEnvironmenVariable("SYSTEMROOT") & "\system32\msg.exe")) Then
  ' run it
Else
  MessageBox.Show("msg.exe" could not be found") ' or attempt net send but I still don't see how to run it
End If


Edit:
Another suggestion is to catch the KeyPress event for Message and invoke the Send button. Something like:
Code:
Private Sub txtMessage_KeyPress(sender As Object, e As KeyPressEventArgs)
  If e.KeyChar = Convert.ToChar(13) Then
    send_Click(Me, New EventArgs())
    e.Handled = True
  End If
End Sub
 
Last edited:

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
By the way, all the version numbers are on here:
http://en.wikipedia.org/wiki/History_of_Microsoft_Windows#Product_progression

I don't know if Windows 2000 has msg.exe or not. Doing some Googling, it appears that Windows 2000 has msg.exe but some distros of Windows Vista does not (Home Basic and Home Premium).

In any case, you should add a check for the file before attempting to execute it:
Code:
If System.IO.File.Exists(Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\msg.exe"))
  ' run it
Else
  MessageBox.Show("msg.exe" could not be found") ' or attempt net send but I still don't see how to run it
End If


Edit:
Another suggestion is to catch the KeyPress event for Message and invoke the Send button. Something like:
Code:
Private Sub txtMessage_KeyPress(sender As Object, e As KeyPressEventArgs)
  If e.KeyChar = Convert.ToChar(13) Then
    send_Click(Me, New EventArgs())
    e.Handled = True
  End If
End Sub

I am having issues with

Code:
Environment.GetEnvironmentalVariable
Seems not to work...
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
Environment.GetEnvironmentVariable()


It works on Server 2003 but I had Windows 7/Vista checked.
 

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
It is Environment, not Environmental (my brain fart, I got right a post or two before that :laugh:). I fixed the code you quoted of mine.
 

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
Great! You forgot the "then" as well... Works now, also, I need someone to test it with the new code in it who DOES NOT HAVE MSG.exe!!! Also, for the test button... I was planning on having it send a message back to the user... I tried saying the user was "127.0.0.1" but no luck! Any ideas?

Edit: Ok we kinda are dumb ... what happens if the user is using Windows 2000 which does not have MSG.exe, but still uses the net send command? I will fix... those radio buttons are lifesavers!

Edit2: Problem solved:

 

Attachments

  • Easy Msg.exe
    49.5 KB · Views: 771
Last edited:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
You shouldn't need the radio buttons...
Code:
If Environment.OSVersion.Platform <> PlatformID.Win32NT Then
  ' Windows 9x or other, not suported
Else
  If System.IO.File.Exists(Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\msg.exe") Then
    ' Use msg
  Else
    If System.IO.File.Exists(Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\net.exe") And Environment.OSVersion.MajorVersion < 6 Then
      ' Use net send
    Else
      ' Not supported
    End If
  End If
End If

You should really make the path to msg and the path to net readonly variables:
Code:
Private ReadOnly PATH_MSG As String = Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\msg.exe") 
Private ReadOnly PATH_NET As String = Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\net.exe")
Instead of typing that whole lot, you'd only have to type PATH_MSG or PATH_NET.


Edit: I updated both code areas in this post...
 
Last edited:

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
You shouldn't need the radio buttons...
Code:
If Environment.OSVersion.Platform <> PlatformID.Win32NT Then
  ' Windows 9x or other, not suported
Else
  If System.IO.File.Exists(Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\msg.exe") Then
    ' Use msg
  Else
    If System.IO.File.Exists(Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\net.exe") And Environment.OSVersion.MajorVersion < 6 Then
      ' Use net send
    Else
      ' Not supported
    End If
  End If
End If

You should really make the path to msg and the path to net readonly variables:
Code:
Private ReadOnly PATH_MSG As String = Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\msg.exe") 
Private ReadOnly PATH_NET As String = Environment.GetEnvironmentalVariable("SYSTEMROOT") & "\system32\net.exe")
Instead of typing that whole lot, you'd only have to type PATH_MSG or PATH_NET.


Edit: I updated both code areas in this post...

Ok great! I fixed most of the code to automate choosing the Windows version.
 

Attachments

  • Easy Msgr.exe
    54.5 KB · Views: 797

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
Having trouble calling a media file from resources. How would I accomplish this?

Code:
AxWindowsMediaPlayer1.URL = "My.Resources.music.mid"

The above code does not work.
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.

PVTCaboose1337

Graphical Hacker
Joined
Feb 1, 2006
Messages
9,501 (1.43/day)
Location
Texas
System Name Whim
Processor Intel Core i5 2500k @ 4.4ghz
Motherboard Asus P8Z77-V LX
Cooling Cooler Master Hyper 212+
Memory 2 x 4GB G.Skill Ripjaws @ 1600mhz
Video Card(s) Gigabyte GTX 670 2gb
Storage Samsung 840 Pro 256gb, WD 2TB Black
Display(s) Shimian QH270 (1440p), Asus VE228 (1080p)
Case Cooler Master 430 Elite
Audio Device(s) Onboard > PA2V2 Amp > Senn 595's
Power Supply Corsair 750w
Software Windows 8.1 (Tweaked)
MIDI is going to be trouble. Can you convert it to a .wav? In wave format, you can use System.Media.SoundPlayer.

I actually got it to play, but the music / midi file has to be in the same folder. Simply need to know how to call from resources.

Code:
AxWindowsMediaPlayer1.URL = "music.mid"
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
Oh, embeded in your executable? Usually it is:

AssemblyName.Properties.Reserouces.name_of_resource
 
Top