|
The problem is that the shell commands never get ran it seems. When I type it in the command prompt it works fine, but when I:
Shell("Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnport.vbs -a -r CSE-ATLAB-BWQ -h at-cetus.ad.ufl.edu -o lpr -q CSE-ATLAB-BWQ")
It never runs. Did I use the wrong command?
|
|
|
|
|
Look into the Process class and it's Start method.
|
|
|
|
|
Process.Start("Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r CSE-211-CLQ -h at-cetus.ad.ufl.edu -o lpr -q cse-211-clq")
The above doesn't execute. Nothing else after it gets run either. When I do a Process.Start("Iexplorer.exe") it runs. What am I doing wrong? Does it help that I am running 2 shell commands per printer for 18 printers?
|
|
|
|
|
Trey5498 wrote: The above doesn't execute. Nothing else after it gets run either
It appears youre thread quit for an unexpected reason or it threw an exception that you ate and ignored.
Trey5498 wrote: What am I doing wrong?
I have no idea without seeing the code that setups up the thread and the code it's running.
|
|
|
|
|
Imports Microsoft.Win32
Public Class prnProcessing
Dim x As New System.Diagnostics.Process
Public arrInstalled As New ArrayList()
Dim WithEvents ToDoWork As New System.ComponentModel.BackgroundWorker
Public Sub prnProcessing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If prnSelection.arrToInstall.Count > 0 Then
'added 10-2-08
prnProgress.Style = ProgressBarStyle.Continuous
'prnProgress.Dock = DockStyle.Bottom
prnProgress.Visible = False
prnProgress.Minimum = 1
prnProgress.Maximum = prnSelection.arrToInstall.Count
'end add 10-2-08
ToDoWork.WorkerReportsProgress = True
ToDoWork.WorkerSupportsCancellation = True
ToDoWork.RunWorkerAsync(prnSelection.arrToInstall)
Me.CenterToScreen()
Else
MsgBox("There are no printers to install. Please choose the printers you wish to install.")
prnSelection.Show()
Me.Close()
End If
End Sub
Public Sub ToDoWork_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles ToDoWork.DoWork
Dim worker As System.ComponentModel.BackgroundWorker = CType(sender, System.ComponentModel.BackgroundWorker)
If e.Argument IsNot Nothing AndAlso TypeOf (e.Argument) Is ArrayList Then
Dim arrToInstall As ArrayList = e.Argument
If arrToInstall.Count > 0 Then
Dim i As Integer = 1
For Each printer As String In arrToInstall
CallByName(Me, printer, CallType.Method)
worker.ReportProgress(i)
i += 1
System.Threading.Thread.Sleep(200)
Next
End If
End If
End Sub
Public Sub ToDoWork_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles ToDoWork.ProgressChanged
prnProgress.Visible = True
prnProgress.Value = e.ProgressPercentage
End Sub
Public Sub PrinterProgress(ByVal i As Integer, ByVal worker As System.ComponentModel.BackgroundWorker, ByVal e As System.ComponentModel.DoWorkEventArgs)
worker.ReportProgress(i)
End Sub
Public Sub ToDoWork_EndProgress() Handles ToDoWork.RunWorkerCompleted
ToDoWork.Dispose()
prnWrapup.Show()
Me.Close()
End Sub
Public Sub CSE211CLQ()
'Added on 10/27/2008
Process.Start("cmd", "Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r CSE-211-CLQ -h at-cetus.ad.ufl.edu -o lpr -q cse-211-clq")
Process.Start("cmd", "rundll32 printui.dll, PrintUIEntry /if /b ""CSE-211-CLQ"" /f ""C:\7760.inf"" /q /r ""CSE-211-CLQ"" /m ""Xerox Phaser 7760GX PS"" /z /u")
arrInstalled.Add("CSE-211-CLQ")
'end Added on 10/27/2008
'for test purposes
MsgBox("CSE-211-CLQ Installed", vbOK)
End Sub
End Class
Here is the form that contains the BGworker and Dos commands. I truncated the printers to one so that it wont be spam. I added the "cmd" to see if that would make a difference and it still doesnt work, however the command prompt pops up and everything else executes, just not the adding of the printer/port.
|
|
|
|
|
Utter spaghetti. There's stuff that there's no definitions for. Example: What's prnSelection.arrToInstall ? Where is it defined? How is it getting passed to this code, ...
And what's with this CallByName garbage?? Don't. Just put the printer names and the two command lines you need to run for them into an array and you can loop through building the command lines and launching them from that. If you think you need to use CallByName, you really need to rethink your design.
You may also want to look into changing the Process.Start commands. The .exe to run would be "Cscript" and "rundll32", not "cmd".
|
|
|
|
|
there are 4 forms in this project
(form 1) prnSelections - Has 18 checkboxes so the user can select what they wish and ONLY install those.
arrToInstall is an arraylist that is filled when the check boxes are check upon clicking the next button
(form 2) prnOverView - Doesn't show up here as it is just the middle man for the user to make sure of the printers
(form 3) prnProcessing - which installs the printers.
(form 4) prnWrapup - Another form just to show which have successfully been installed hince the reason I was looking for an easy way to check the port/printer has been created so I do not attempt to install it more than once.
CallByName is used to call the installation function because printer is the value of that particular spot in the arraylist.
I tried without the BGworker before, however the progressbar would not get filled as that is what I need.
I hope this clears up a few things of what I am trying to accomplish.
and do you mean Process.Start("Cscript.exe %WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r CSE-211-CLQ -h at-cetus.ad.ufl.edu -o lpr -q cse-211-clq") ?
modified on Wednesday, October 29, 2008 10:07 AM
|
|
|
|
|
Trey5498 wrote: Process.Start("Cscript.exe %WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r CSE-211-CLQ -h at-cetus.ad.ufl.edu -o lpr -q cse-211-clq")
No, I mean:
Process.Start("cscript.exe", """%WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs"" -a -r CSE-211-CLQ -h at-cetus.ad.ufl.edu -o lpr -q cse-211-clq")
|
|
|
|
|
it brought up the cmd prompt quick, then went away and still never installed the port/printer. Here is what I changed it to:
Process.Start("Cscript.exe", """%WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs"" -a -r CSE-211-CLQ -h at-cetus.ad.ufl.edu -o lpr -q cse-211-clq")
Process.Start("rundll32.exe", "printui.dll, PrintUIEntry /if /b ""CSE-211-CLQ"" /f ""C:\7760.inf"" /q /r ""CSE-211-CLQ"" /m ""Xerox Phaser 7760GX PS"" /z /u")
It is like it just ignores the arguments completely! I am using VS 2008 if that helps
|
|
|
|
|
I have a vb.net application, In which the use of MS ScriptControl invoke Perl app.
e.g:
-------------------------------------------
DIM MSS AS NEW SCRIPTCONTROL
MSS.Language = "PerlScript"
MSS.Reset()
MSS.AllowUI = False
MSS.UseSafeSubset = False
MSS.AddCode("Test")
////////////////////////////
PERL APP.
sub Test(){
$a=1;
$b=2;
$c=$a+$b;
print("This is a test!!!\n");
return $c;
}
------------------------------------------
This program can run normally, But I want perl app. print out the data!
How do i do?
|
|
|
|
|
I have no idea since I've never used the MSScript control. But, this line: MSS.AllowUI = False , looks like it may prevent you from doing what you want.
|
|
|
|
|
OK ,i'll try it again.
Thank you proposal
|
|
|
|
|
Hi guys
I am getting the following warning .
"Found conflict between the different versions of the same assembly"
any help
thanks in advance
hello
|
|
|
|
|
Google results for ""Found conflict between the different versions of the same assembly"[^]".
Basically, you have two parts of your solution that refer to the same assembly, but where setup using different versions of that assembly. If your familiar with ILDASM, you can use that to see which assemblies you're referencing are using different versions. But, in the end, you're just going to end up recompiling the dependant assemblies and your projects that use them.
|
|
|
|
|
Hi All,
I am using Enteprise Library Data Access Application Block (v 3.0 April 2007) in my application.I want to encrypt the App.config file. I have tried the bulit-in RSA and Data encryption metods in Data Access Application block.
It seemed that the user account who creates the encryption key only has the key to decrypt it. That means it's machine dependant.
Eg. If i encrypt the config file in my machine my collegue can't decrypt it in his machine. Is there any way that we can encrypt the file using a public key which is accessible to the other developers in the team? Can anybody suggest me a way to overcome this issue?
Thanx in advance,
Dinesh
|
|
|
|
|
The way I've gotten around this is to not ship an encrypted app.config. You encrypt the app.config using a custom action in the installer project. This encrypts the app.config file when the application is installed on the target machine.
|
|
|
|
|
I end up creating my own encryption routine to encrypt the data prior to getting written to the config. The key is skewed and the code is obfuscated for better protection; our apps are used by our internal employees only.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I just want to test first if my code is running so i rewrite everything and created a simple insert command, but it wasn't working right. When i update my adapter i had an error"syntax error in insert into" i don't know what code to edit or did i miss something?
please help. thanks.
Try
Dim myConnection As New OleDb.OleDbConnection
Dim myAdapter As New OleDb.OleDbDataAdapter
myConnection.ConnectionString = "Provider= Microsoft.Jet.OLEDB.4.0; Data
Source=C:\Desktop\vbnet\biblio.mdb"
myAdapter = New OleDb.OleDbDataAdapter("Select * from Titles", myConnection)
Dim ds As DataSet = New DataSet
Dim dr As DataRow
Dim drCommandBuilder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
myAdapter.Fill(ds, "Titles")
MessageBox.Show("Loaded data from Titles Table into dataset.")
myConnection.Close()
dr = ds.Tables("Titles").NewRow()
dr("ISBN") = "026"
dr("Title") = "Together Again"
dr("Year Published") = "2001"
ds.Tables("Titles").Rows.Add(dr)
MessageBox.Show("Inserted new row into Titles")
myConnection.Open()
myAdapter.Update(ds, "Titles")
MessageBox.Show("Sent update to db")
Catch Ex As Exception
Console.WriteLine("Error: " & Ex.Message)
MsgBox("Error: " & Ex.Message)
End Try
|
|
|
|
|
The problem is in your select statement. You told it to return all fields with the "*". The command builder can't construct an SQL statement using the "*". You have to specify the field names you're using in the SELECT statement so the command builder can figure out which values go in which fields when it builds the INSERT statement.
|
|
|
|
|
im new in using ole db and i could'nt solve my problem here. not sure if im missing some codes.
after clicking the save button and closing the program, when you open it again, the record will not show (not actually saved!). I need to add, edit and delete a record.
please help. thanks.
If strMode = "addmode" Then
dr = dt.NewRow()
dr("ISBN") = txtISBN.Text
dr("Title") = txtTitle.Text
dr("Year Published") = txtYear.Text
'dt = ds.Tables(0)
dt.Rows.Add(dr)
myAdapter.AcceptChangesDuringFill = True
dr.AcceptChanges()
dr.BeginEdit()
Me.myAdapter.Update(ds)
MessageBox.Show("Added new record!")
ElseIf strMode = "editmode" Then
'cm = currencymanager
dt.Rows(cm.Position).Item("ISBN") = txtISBN.Text
dt.Rows(cm.Position).Item("Title") = txtTitle.Text
dt.Rows(cm.Position).Item("Year Published") = txtYear.Text
Me.myAdapter.Update(ds)
MessageBox.Show("Record Updated!")
End If
Reply·Email·View Thread
|
|
|
|
|
Please don't repost the same question again.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
You might also want to get rid of that "AcceptChanges" line. You'll want to read up on it before you use it so you know exactly what it does and why it appears to be throwing out your changes.
|
|
|
|
|
I am using parallel port in my design project.May you please give me a detailed description how to do so.My I design is based on controlling the following outputs 12V stepper motor,buzzer and traffic lights(3 Leds).
I am using 2 motion detector (both main and the backup) to sense the train and pressure sensor to detect the car(this are my inputs).
Please help I am submitting this project on 3 of November2008.Please help I was trying since july.
modified on Monday, October 27, 2008 6:45 PM
|
|
|
|
|
One week to do this?? Good Luck with that! You'll find it very difficult to do this with the parallel port. Too limited in functionality and interfacing between the hardware and your code. You can do this much easier using USB devices. Check out Trossen Robotics[^], starting with a Phidgets board and the sensors and motor controllers they have.
|
|
|
|
|
im new in using ole db and i could'nt solve my problem here. not sure if im missing some codes.
after clicking the save button and closing the program, when you open it again, the record will not show (not actually saved!). I need to add, edit and delete a record.
please help. thanks.
If strMode = "addmode" Then
dr = dt.NewRow()
dr("ISBN") = txtISBN.Text
dr("Title") = txtTitle.Text
dr("Year Published") = txtYear.Text
'dt = ds.Tables(0)
dt.Rows.Add(dr)
myAdapter.AcceptChangesDuringFill = True
dr.AcceptChanges()
dr.BeginEdit()
Me.myAdapter.Update(ds)
MessageBox.Show("Added new record!")
ElseIf strMode = "editmode" Then
'cm = currencymanager
dt.Rows(cm.Position).Item("ISBN") = txtISBN.Text
dt.Rows(cm.Position).Item("Title") = txtTitle.Text
dt.Rows(cm.Position).Item("Year Published") = txtYear.Text
Me.myAdapter.Update(ds)
MessageBox.Show("Record Updated!")
End If
|
|
|
|