Hellooooooooo
Technical User
Hello everyone.
So I have small problem. I have 2 users that have a need to run DOS commands, however our lockdowns don't allow this to happen.
The 1st user needs to ping an IP address before he can carry out a job. Ive cobbled together the following from the web.
Option Explicit
Dim Shell, strCommand, strHost, strUserIn, ReturnCode
Dim Message, result
Dim Title, Text1
'Message Box Variables.
Message = "Please enter the address you wish to ping"
Title = "PingPong, K.I.S.S."
Text1 = "User abort"
'Text2 = "You entered:" & vbCrLf
result = InputBox(Message, Title, "127.0.0.1", 8000, 6000)
'Evaluate the user input.
If result = "" Then ' Canceled by the user
WScript.Echo Text1
Else
'WScript.Echo Text2 & result
strHost = vbCrLf
'Create shell object
Set Shell = wscript.createObject("wscript.shell")
'What to run in command line
strCommand = "ping -n 1 -w 10 " & strHost
'Run command and get return code
ReturnCode = Shell.Run(strCommand, 0, True)
'0 = pingable, 1 = no response
If ReturnCode = 0 Then
wscript.echo strHost & " pingable"
Else
wscript.echo strHost & " not pingable"
'End If
End If
End If
Running this should ask for the address to be pinged then nreturn a popup if its pingable. I can get it to take an IP address, but it wont return a result.
The 2nd user is a nightmare. He needs to use DOS to run the DIR command with a few switches and return the result to a text file. This VBS script should take his command as he types it and complete it for him.
Any pointers??? this is causing me a nightmare as they are asking for full admin rights to do this. By the way this is all running on NT4 ang Win2k boxes.
Any help would be grand.
Thanks
So I have small problem. I have 2 users that have a need to run DOS commands, however our lockdowns don't allow this to happen.
The 1st user needs to ping an IP address before he can carry out a job. Ive cobbled together the following from the web.
Option Explicit
Dim Shell, strCommand, strHost, strUserIn, ReturnCode
Dim Message, result
Dim Title, Text1
'Message Box Variables.
Message = "Please enter the address you wish to ping"
Title = "PingPong, K.I.S.S."
Text1 = "User abort"
'Text2 = "You entered:" & vbCrLf
result = InputBox(Message, Title, "127.0.0.1", 8000, 6000)
'Evaluate the user input.
If result = "" Then ' Canceled by the user
WScript.Echo Text1
Else
'WScript.Echo Text2 & result
strHost = vbCrLf
'Create shell object
Set Shell = wscript.createObject("wscript.shell")
'What to run in command line
strCommand = "ping -n 1 -w 10 " & strHost
'Run command and get return code
ReturnCode = Shell.Run(strCommand, 0, True)
'0 = pingable, 1 = no response
If ReturnCode = 0 Then
wscript.echo strHost & " pingable"
Else
wscript.echo strHost & " not pingable"
'End If
End If
End If
Running this should ask for the address to be pinged then nreturn a popup if its pingable. I can get it to take an IP address, but it wont return a result.
The 2nd user is a nightmare. He needs to use DOS to run the DIR command with a few switches and return the result to a text file. This VBS script should take his command as he types it and complete it for him.
Any pointers??? this is causing me a nightmare as they are asking for full admin rights to do this. By the way this is all running on NT4 ang Win2k boxes.
Any help would be grand.
Thanks