Hello Folks,
Today i would share with you script to convert a virtual application to web application in IIS manager. This was a bit headache, since i had to try hell lot of things before narrowing down to script. Anyways, following are the two scripts
For Adding entry to IIS
Option Explicit
On Error Resume Next
dim objshell,win, AppCMD, strc
set Objshell=CreateObject("Wscript.Shell")
win = Objshell.ExpandEnvironmentStrings("%WINDIR%")
AppCMD=Win & "\system32\inetsrv\appcmd.exe" 'appcmd converts your virtual apps to web in IIS manager
'======================register the app in IIS==============================================
strc = chr(34) & appcmd & chr(34) & " add app /site.name:" & chr(34) & "Default Web Site" & chr(34) & " /path:" & chr(34) & "/<Name of the application>" &chr(34) & " /physicalPath:" & chr(34) & "C:\inetpub\wwwroot\<Name of application>" & chr(34)
objshell.Run StrC,0,TRUE
Set ObjShell=Nothing
For removing entry from IIS manager
Option Explicit
On Error Resume Next
dim objshell,win, AppCMD, strc
set Objshell=CreateObject("Wscript.Shell")
win = Objshell.ExpandEnvironmentStrings("%WINDIR%")
AppCMD=Win & "\system32\inetsrv\appcmd.exe"
'======================remove the app in IIS==============================================
strc = chr(34) & appcmd & chr(34) & " delete app /app.name:" & chr(34) & "Default Web Site" & "/<Name of application>" & chr(34)
objshell.Run StrC,0,TRUE
Set objshell=Nothing
Hop you guys find it useful. Cheers
Comments