Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Run iisreset.exe from a VB app

Status
Not open for further replies.

JohnBates

MIS
Joined
Feb 27, 2000
Messages
1,995
Location
US
hi everyone,

First, this post should be in the VB 6 forum but that one seems to be down at the moment.

Sometimes our webserver gets locked-up and we have to go to that server (Windows 2000 Server running IIS 5) and run a Microsoft tool named iisreset.exe from the command line to fix the problem.

What I want to do is build a VB 6 app I can use from my desk to execute iisreset.exe on that server. My PC and the server are on the same network.

Can I do this with a VB app ?
Thanks for your ideas. John
 
Have you considered VNC or Remote Access (Terminal Services) to allow for remote access and then simply run the command?

I believe that what you are asking for is not going to result in many valid replies since this type of code could be considered malicious in possible uses. I.E., run the code from an email received and my IIS server resets.

Andy

Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
That's a good suggestion Andy.

But because this is a webserver, they have disabled Terminal Services - in general the 'security screws' are tight on this server.

I do have the VB app developed now. But it isn't resetting IIS at this time. More work to do....

Thanks for replying.
John
 
Yea, I figured as much. You may want to post some of your relevant code.

Andy

Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
Sure, heres the code. I had to copy the iisreset.exe object onto my PC. You'll notice it executes locally.

When I run it, nothing happens - no error. And Event Viewer log on server indicates nothing happened.

But Event log on my PC shows:
"DCOM got error General Access Denied from computer memphisweb..."


Thanks. John

Private Sub cmdReset_Click()
Dim RetVal

If LstServers.Text = "memphisweb" Then
'RetVal = Shell("\\memphisweb\winnt$\system32\iisreset /memphisweb") error 5
'RetVal = Shell("\\memphisweb\winnt$\system32\iisreset memphisweb /restart") err 5
'RetVal = Shell("\\memphisweb\winnt$\system32\iisreset.exe memphisweb /restart")
'RetVal = Shell("\\memphisweb\winnt$\system32\iisreset.exe memphisweb /restart"), vbNormalFocus compile/syntax error
'RetVal = Shell("\\memphisweb\winnt$\system32\iisreset.exe memphisweb /restart, 1") error 5 Invalid procedure call or argument
'RetVal = Shell("\\memphisweb\winnt\system32\iisreset /memphisweb") ran, no error but did not reset iis
'RetVal = Shell("\\memphisweb\winnt\system32\iisreset memphisweb /restart") ran, no error but did not reset iis
'RetVal = Shell("\\memphisweb\winnt\system32\iisreset.exe memphisweb /restart") ran, no error DID IT RESET ? no
'RetVal = Shell("\\memphisweb\winnt\system32\iisreset.exe memphisweb /restart"), vbNormalFocus compile/syntax error
'RetVal = Shell("\\memphisweb\winnt\system32\iisreset.exe memphisweb /restart, 1") ran, but did not reset iis
'RetVal = Shell("\\memphisweb\winnt\system32\iisreset.exe") did not reset
'Shell "c:\iisreset.exe memphisweb /restart" this creates a log entry in my Event Viewer General access denied error from memphisweb when attempting to activate the server - at least it tried to run
'RetVal = Shell("\\memphisweb\C:\winnt\system32\iisreset.exe memphisweb /restart, 1") error 5 Invalid procedure call or argument

'** Think this one has correct syntax - but it doesnt reset iis on the server **

Shell "c:\iisreset.exe memphisweb /restart"

End If

'Shell "iisreset memphisweb /restart", vbNormalFocus gives error 53 File not found
'RetVal = Shell("iisreset memphisweb /restart") also get error 53 file not found
'RetVal = Shell("\\memphisweb\winnt$\iisreset memphisweb /restart") gives error 5 invalid procedure call or argument


End Sub
 
MY WINDOWS XP MACHINE WAS INFECTED WITH A NASTY WORM AND i GO INTO SOME DLL FILES AND HELP FILES AND FIND THE FILE BEGINS WITH "MZ". wHAT IS MZ AND IS IT A VB COMMAND?
aNY HELP WOULD BE GREAT
THANKS
 

MATTYB420
Start by reading faq222-2244 which shows you how to use this site. Then find do your basic research, then find the right forum, then ask a clear question without SHOUTING.

That way you stand a chance of getting a useful answer

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks johnwm for straightening MATTYB420 out.

Now that my thread is back to the top....

When I run my VB app, which resides locally on my PC and runs iisreset.exe also on my PC, I get this error:

Event log on my PC shows:
"DCOM got error General Access Denied from computer memphisweb..."

This of course sounds like a permissions problem.
Any ideas on how to get around it?

Thanks, John

 
Well, firstly you have to be a member of the Administrators group to be able to run iisreset successfully. Can you confirm whether the account you are running the VB program from is a member of that group?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top