|
I want to write a windows service that shuts down the computer between 4:30am and 5:30 am every morning provided nobody is currently logged in. The computer is running XP professional, and the windows service I wrote uses the account "LocalSystem".
I have been able to create a windows service, and determine if anyone is logged in but I am running into problems with the shutdown command. I have a timer to check if conditions are right (ie. nobody logged in, and within the specified reboot time interval) and then I run the following code to shut down the system:
System.Diagnostics.Process.Start("Shutdown", "-s -t 1")
I can't seem to get this to work unless I am logged in. If I am not logged it, it does nothing until I log in and then immediately shuts me down. "Shutdown" seems to require a logged in user. Is there a way to shutdown the computer when I am not logged in?
Thanks.
|
|
|
|
|
I am guessing it has to do with some of the setting on the process. There are some things you can set like
Process.StartInfo.CreateNoWindow = false
Hope that helps.
Ben
|
|
|
|
|
At runtime I have a button and other controls that load images from a file,
below is one example,
DIYButton.BackgroundImage = Image.FromFile(ChosenPath & "\DIY.gif")
What I want is to have it load the image, if it's a gif or jpg
How do I go about it?
|
|
|
|
|
Something like this, maybe:
If My.Computer.FileSystem.FileExists(ChosenPath & "\DIY.gif") = True Then
DIYButton.BackgroundImage = Image.FromFile(ChosenPath & "\DIY.gif")
ElseIf My.Computer.FileSystem.FileExists(ChosenPath & "\DIY.jpg") = True Then
DIYButton.BackgroundImage = Image.FromFile(ChosenPath & "\DIY.jpg")
End If
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
|
You can name the file whatever you like, it will still open as either a gif or jpeg, based on it's format. You can use File.Exists to check if the file is there in either format, also.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Such thing are better if you could do bit of R&D which may result in bubbling of new things and Ideas.
Develop2Program & Program2Develop
|
|
|
|
|
I want to use a LinkButton because i want when it have been clicked do somthing and i want when it have been right clicked and press Open in new window a new page appears but i don't know how can i open new window.
Please help me.
Thanks in advance.
|
|
|
|
|
In the code for your LinkButton type: Process.Start("http://www.example.com") . This will open a new tab/window in your default browser.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
I have looked for ever for this information. Does anyone know of a good tutorial or description of how to receive information from the sound card, c#,VB.net or VBA preferably. I am a ham radio operator and would like to write my own Morse Code decoder via sound card interface. There are many out there but I want to integrate this into a radio control program
Harry8227
|
|
|
|
|
You put this in a Dispose implementation?? What are you trying to do with this code? This is something you would normally find in a form's Closing event, not Dispose.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi:
Supouse I have this Table in a Access database:
Table Name: CostumersType
Fields: ID(Autonumber),Name(text(50)), Costumers(object)
And this Class
Class Name: Costumers
Class Properties: name(string),id(integer)
And i add some items of the class costumers to an arraylist called Costumers.
Then I want to save the content of the arraylist to the field costumer of the database. And I don't know how.
Guille
|
|
|
|
|
This is not a possible i think and not a good approach either.
Why you need to put arraylist in the table field?
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi,
I developed an windows application that inserts some values into database.It is working fine.But now i have two problems
1) I prepared an exe file for my application and installed in another system. When i executed my application in that system it given me error as it doesn't find database. I have given the Datasource as "Data Source=D:\Dotnet\SurveyApp\SurveyApp\SurveyData.mdb".
Can any one suggest me what i have to do to solve this
2)I have another doubt i.e is it necessary that ms access should be installed the syystem where i installed my application?
Please help me solve
Thanks
vijay
|
|
|
|
|
vijay2583 wrote: I prepared an exe file for my application and installed in another system. When i executed my application in that system it given me error as it doesn't find database. I have given the Datasource as "Data Source=D:\Dotnet\SurveyApp\SurveyApp\SurveyData.mdb".
Can any one suggest me what i have to do to solve this
And is that the location of the database on the new machine? If not then it seems fairly obvious to me that you need to change the location of the database in the datasource. If this value is hard coded then you might want to learn the lesson not to hard code file paths in an application.
So, where is the database now?
vijay2583 wrote: I have another doubt i.e is it necessary that ms access should be installed the syystem where i installed my application?
That depends. Do you intend to share the data? If yes, then SQL Server is probably a better option as it is more able to share data between multiple machines. If not, then you probably want to copy the database.
|
|
|
|
|
Good way to learn some Grammer of Software
Develop2Program & Program2Develop
|
|
|
|
|
Hello every one
I am doing one project with random file function and i have problem with file open but i can open file in my list box but i can not open file in text box i have three variable id , name , and weight, in find event i put one button and three text box so when user put id in first text box and click find button it should display name and weight in other two text box but it's not so any help, this is what i have done so far
Structure Ink<br />
Dim Weight As String<br />
Dim InkID As String<br />
Dim InkName As String<br />
End Structure<br />
Private Function FindLastRecordNo() As Integer<br />
Dim Temp As Ink<br />
FileNumber = FreeFile()<br />
FileOpen(FileNumber, "c:\inklist.txt", OpenMode.Random, OpenAccess.Read, , Len(Temp))<br />
FindLastRecordNo = 1<br />
Do While Not EOF(FileNumber)<br />
FileGet(FileNumber, Temp, )<br />
FindLastRecordNo = FindLastRecordNo + 1<br />
Loop<br />
FileClose(FileNumber)<br />
End Function<br />
<br />
I have no problem with this event <br />
<br />
<code>Private Sub btnOpenList_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpenList.Click<br />
Dim MyInk As Ink, Count As Integer, Temp As String<br />
Dim MyLine, MySubString As String, LineWidth As Integer = 60<br />
FileNumber = FreeFile()<br />
FileOpen(FileNumber, "c:\inklist.txt", OpenMode.Random, , , Len(MyInk))<br />
Count = 1<br />
lstInk.Items.Clear()<br />
Do While Not EOF(FileNumber)<br />
FileGet(FileNumber, MyInk, Count)<br />
Temp = MyInk.InkID + MyInk.InkName + MyInk.Weight<br />
lstInk.Items.Add(Temp)<br />
Count = Count + 1<br />
Loop<br />
FileClose(FileNumber)
End Sub
but i have problem with find click event it's not showing any thing in textbox
<code>Private Sub btnFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFind.Click<br />
Dim MyInk As Ink<br />
FileNumber = FreeFile()<br />
FileOpen(FileNumber, "c:\inklist.txt", OpenMode.Random, , , Len(MyInk))<br />
Do While Not EOF(FileNumber)<br />
FileGet(FileNumber, MyInk, )<br />
If MyInk.InkID = txtID.Text Then<br />
Position = Loc(FileNumber)<br />
txtIName.Text = MyInk.InkName - this is the problem:confused:<br />
txtIWeight.Text = MyInk.Weight - this is the problem :confused:<br />
Exit Do<br />
End If<br />
Loop<br />
FileClose(FileNumber)<br />
End Sub
any help
wating for your kind help
|
|
|
|
|
You're going to have to put a breakpoint on the FileOpen statement in the btnFind_Click event, then step through the code line by line and watch what's happening in each of the variables in your Do/While loop. It looks like you never find the data your trying to search for.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
hello sir
first of all thanks for your kind rep.
this the first code for suructure
Structure Ink<br />
Dim Weight As String<br />
Dim InkID As String<br />
Dim InkName As String<br />
End Structure
thsi is code for structure and now i have changed to this
Structure Ink<br />
Dim Weight As String<br />
Dim InkID As Integer (this is what i have changed )<br />
Dim InkName As String<br />
End Structure
and it's working but now there is another problem is's not showing InkID in listbox it's only shows number "0" for all entrys
so can you help me with this
wating for your kind rep.
|
|
|
|
|
Dear All,
Is it possible to write a string from vbscript to console. How can we write that?
regds
Shihab
|
|
|
|
|
You might be able to use Wscript.Echo("A String")
|
|
|
|
|
So long as you run your script with the CSCRIPT exe instead of the default WSCRIPT version, all you need is WScript.Echo "message..." .
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
I am writing a RFID driver and I face a problem in writting "set baseband filter"
Here is the problem
Filter mask:
H G D B C E
1/0 1/0 1/0 1/0 1/0 1/0
I want to use Window application form in visual basic language to do this. If the Filter H,B,C of the filter turn on, Filter mask byte should set to &H4C. If all the filter turn on, The mask byte will be &H3F.
So how to write this??
If H,B,C of the filter on,shall I get the string "1 0 0 1 1 0"
and convert it into binary , and then to hexidecimal?? If yes, how to convert it?
If no, any easy way to do this programme??
Thank you for your suggestion.
|
|
|
|
|
It isn't advisable to use VB.NET or any other .NET language to write a driver.
|
|
|
|
|
Hi,
I need to convert this coding VB 5.0 to VB.Net 2003. This print button coding in billing system. I use BIXOLON SAMSUNG SRP-275 mini printer. There was sample coding but it's in VB 5.0. But I write my program in VB.Net 2003.
This is the coding......
'//////////////////////////////////////////////////////////////////
Private Sub Command1_Click()
For Each prnPrinter In Printers
If prnPrinter.DeviceName = "BIXOLON SAMSUNG SRP-275" Then
Set Printer = prnPrinter
Exit For
End If
Next
If Printer.DeviceName = "BIXOLON SAMSUNG SRP-275" Then
Printer.Font.Size = 9
Printer.FontName = "FontControl"
Printer.Print "x"
Printer.Font.Size = 9
Printer.FontName = "FontA2x1"
Printer.Font.Bold = True
Printer.Print "* Joshua Cafe *" + vbCrLf
Printer.Font.Bold = False
Printer.Font.Size = 9
Printer.FontName = "FontControl"
Printer.Print "w"
Printer.Font.Size = 9
Printer.FontName = "FontA1x1"
Printer.Print " 3000 Spring Street, Rancho,"
Printer.Print " California 10093,"
Printer.Print " Tel) 858-519-3698 Fax) 3852"
Printer.Print vbCrLf + "---------------------------------" 'LF
Printer.Print "Orange Juice 5.00"
Printer.Print "6 Bufalo Wing 24.00"
Printer.Print "Potato Skin 12.00"
Printer.Font.Bold = True
Printer.ForeColor = RGB(255, 0, 0)
Printer.Print "Subtotal 41.00"
Printer.ForeColor = RGB(0, 0, 0)
Printer.Font.Bold = False
Printer.Print "Tax 6% 2.46"
Printer.Font.Bold = True
Printer.ForeColor = RGB(255, 0, 0)
Printer.Print "Member Discount 2.30"
Printer.ForeColor = RGB(0, 0, 0)
Printer.Font.Bold = False
Printer.Font.Bold = True
Printer.Print "Cash 100.00"
Printer.Print "Amt. Paid 41.16"
Printer.Font.Bold = False
Printer.Font.Bold = True
Printer.ForeColor = RGB(255, 0, 0)
Printer.Print "Change Due 58.84"
Printer.ForeColor = RGB(0, 0, 0)
Printer.Font.Bold = False
Printer.Print "---------------------------------"
Printer.Font.Size = 9
Printer.FontName = "FontControl"
Printer.Print "x"
Printer.Font.Size = 9
Printer.FontName = "FontA1x1"
Printer.Print "Member Number : 452331949" + vbCrLf
Printer.Font.Size = 9
Printer.FontName = "FontA1x1"
Printer.Font.Bold = True
Printer.Print "Have a nice day !" + vbCrLf
Printer.Font.Bold = False
Printer.Print "Sale Date: 07/01/03"
Printer.Print "Time: 12:30:45"
Printer.Font.Size = 9
Printer.FontName = "FontControl"
Printer.Print "w"
Dim pic As Picture
Set pic = LoadPicture(App.Path & "\free5_100.bmp")
Printer.CurrentX = 60
Printer.CurrentY = 5000
Printer.PaintPicture pic, Printer.CurrentX, Printer.CurrentY
Printer.CurrentY = Printer.CurrentY + pic.Height
Set pic = LoadPicture(App.Path & "\cafeblue208.bmp")
Printer.PaintPicture pic, Printer.CurrentX, Printer.CurrentY
Printer.CurrentX = 0
Printer.CurrentY = 9000
Printer.Font.Size = 9
Printer.Font.Name = "FontControl"
Printer.Print "g"
Printer.EndDoc
Else
MsgBox "SRP-270 windows driver don't installed"
End If
End Sub
'///////////////////////////////////////////////////////////////////////
Pls help me to solve this problum
Regards
Kusal
|
|
|
|