I have an ASP.NET site I built for our users to map a network printer. When I test it, it maps the printer without any probelms. When I publish it to IIS, it acts like it's going to run, but never tries to map it. Any suggestions or answers will be greatly appreciated. I have checked all the permissions, I have tried it as a web app and a web site, I have tried to publish both and I have tried to copy and paste the folders in the root folder. I have added references to the Microsoft.Powershell.XXXX. I have changed it from "CodeBehind" to "CodeFile" and I have changed the "AutoEventWireup" to "true". I am not sure what else to do now. Thank you.
Imports System.Collections.ObjectModel
Imports System.Management.Automation
Imports System.Management.Automation.Runspaces
Imports System.Text
Imports System.IO
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
If DropDownList1.Text = "ABCD" Then
Label1.Text = " \\ServerB"
End If
If DropDownList1.Text = "EFGH" Then
Label1.Text = " \\ServerC"
End If
If DropDownList1.Text = "IJKL" Then
Label1.Text = " \\ServerD"
End If
If DropDownList1.Text = "MNOP" Then
Label1.Text = " \\ServerE"
End If
'Maps the printer from the selections above.
Label2.Text = "rundll32 printui.dll,PrintUIEntry /q /in /c\\"
Label3.Text = " /n"
Label4.Text = Label2.Text & Label3.Text & Label1.Text & "\" & TextBox3.Text
'Sets it as default
If RadioButton1.Checked = True Then
Label5.Text = Label2.Text & " /y" & Label1.Text & "\" & TextBox3.Text
End If
'Sets it for all users
If RadioButton2.Checked = True Then
Label6.Text = Label2.Text & " /ga" & Label1.Text & "\" & TextBox3.Text
End If
'Powershell commands
Dim printerserver As String = CStr(Label1.Text)
Dim printer As String = CStr(TextBox3.Text)
Dim printcmd As String = CStr(Label2.Text)
Dim networkpath As String = CStr(Label4.Text)
Dim networkdefault As String = CStr(Label5.Text)
Dim allusers As String = CStr(Label6.Text)
Shell(networkpath, AppWinStyle.Hide)
Shell(networkdefault, AppWinStyle.Hide)
Shell(allusers, AppWinStyle.Hide)
'Clears the screen so that a new printer can be added.
TextBox3.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
DropDownList1.Text = ""
End Sub
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" %>