473,408 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Windows startup program problem

shek124
50
I want to run a windows startup program.
here my code:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
  3.     Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal phkResult As Long) As Long
  4.     Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
  5.     Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
  6.     Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal phkResult As Long) As Long
  7.     Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByVal lpType As Long, ByVal lpData As String, ByVal lpcbData As Long) As Long
  8.     Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
  9.     Public Const REG_SZ = 1 ' Unicode nul terminated String 
  10.     Public Const REG_DWORD = 4 ' 32-bit number 
  11.     Public Const HKEY_CLASSES_ROOT = &H80000000
  12.     Public Const HKEY_CURRENT_USER = &H80000001
  13.     Public Const HKEY_LOCAL_MACHINE = &H80000002
  14.     Public Const HKEY_USERS = &H80000003
  15.     Public Const HKEY_PERFORMANCE_DATA = &H80000004
  16.     Public Const ERROR_SUCCESS = 0&
  17.  
  18.  Public Sub SaveString(ByVal Hkey As Long, ByVal strPath As String, ByVal strValue As String, ByVal strdata As String)
  19.         Dim keyhand As Long
  20.         Dim r As Long
  21.         r = RegCreateKey(Hkey, strPath, keyhand)
  22.         r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, strdata, Len(strdata))
  23.         r = RegCloseKey(keyhand)
  24.     End Sub
  25.  
  26.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  27.         'Process.Start("c:\\startup.exe", "startup.txt")
  28.         SaveString(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
  29.             "C:\Documents and Settings\vertical\Desktop\Startup\startup.txt", "C:\Documents and Settings\vertical\Desktop\Startup\startup.txt")
  30.  
  31.     End Sub

when the program runs in VB.net , i get the following error


Error 1 Unable to write to output file 'C:\Documents and Settings\vertical\My Documents\startup\startup\obj\Debug\startup.exe': Access is denied.


Plz help me, i want to view the text file , How do i convert it
Dec 4 '07 #1
2 1555
Shashi Sadasivan
1,435 Expert 1GB
probably you have already tried to run the program once.

does it end in anyway?

What you would need to do it go to task manager find the program and shut it down (it would already be running) and if it is running it is running the exe file as given in the path by you.

on building a project the exe file is created, and it can only be overwritten if it is not in use.
Dec 4 '07 #2
shek124
50
The exe file in not running in the task manger.


you arr not understand about my problem. when i click the start button , the error was occured directly.even not going to debug .


IN the program , when did the running path was written ? i dont know .. also i need to output in .txt file not in .exe file ,.. wat are the replacements i have do in my code. plz help me , thanks for yr reply
Dec 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: clr | last post by:
I'm Using Windows XP and Visual Basic .Net 2002. When I press F5 <Debug/Start>, repeatedly, the program does not always function. However if I consistently press F11 <Step into> and then press F5...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
4
by: duzinga | last post by:
I am trying to have a server program that runs at startup and accepts several commands from the clients. One of the commands is to play an audio file. I am using...
0
by: Stealth3si | last post by:
I hope this is the right thread /forum to place this topic in. I'm trying to execute a .vbs file (double-click) on Windows 2000 Advanced Server with Service Pack 4 (on administrator account) and...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Description NOTE- If you are unfamiliar with the concept of autoruns, then read "Windows Autorun FAQs: Overview". Que-1: How can I safely remove or edit the autorun...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Programs dealing with autoruns Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list programs that help me to view/modify the autoruns...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.