Thread: Need some programming advice.
-
March 4th, 2004, 07:02 PM #1
Need some programming advice.
It's been a while since I've been into programming but I'm thinking of getting back into some basic VB programming.
My currently situation is this.. I work for a company that offers a very basic software package for our customers the only draw back is that each customer must enter account specific data in a number of fields so any time they reinstall the software we have a department that is setup specifically for it and it takes alot of time. In an attempt to make this process less painful I thought about creating a simple program that we as techs could use to create a batch file that we could send to our customers that would allow them to install the software and then run the batch file to set it up for their personal account.
The software uses simple registry entries and *.dat files in the software's directory to hold the configuration settings of the software. So my first question is VB capable of creating a program that would in turn export or create a batch file that can write to both the registry and the DAT files of the software?
-
March 5th, 2004, 02:23 AM #2
-
March 8th, 2004, 02:45 PM #3
-
March 9th, 2004, 03:31 PM #4
^BUMP^ Any chance of getting this moved to the Web Development / Programming forum?
-
March 9th, 2004, 03:35 PM #5
Re: Need some programming advice.
You can use VBS to put in registry entries and copy files to specific locations. You could also use it to start other batch files.Originally posted by Ritalin Kid
...is VB capable of creating a program that would in turn export or create a batch file that can write to both the registry and the DAT files of the software?
-
March 9th, 2004, 05:28 PM #6
My main vision is to create a program that acts as a "Wizard" for the techs in my department to use. Basically we run the wizard and input the customer's acount info into the wizard. When you finish the wizard it exports or creates a batch file that we can send to the customer. After the customer installs our software all they have to do is double click the batch file which enters all the proper information into the registry entries associated with the software and also writes the proper information to the *.DAT files in the programs main directory.
Actually I'm not sure if a batch file would be appropriate and if a batch file is not capable of such a thing what would be?
-
March 9th, 2004, 06:39 PM #7yes you can do this...the wizard and input the customer's acount info into the wizard. When you finish the wizard it exports or creates a batch file that we can send to the customer
As for the editing the DAT files, probably this too, but I'm haven't used a batch file to edit information within a file (I normally just create the file in one step).
-
March 9th, 2004, 07:19 PM #8Not Really a Member
- Join Date
- Oct 2001
- Posts
- 27,856
You could of PM'd me to check the thread

First time I've seen it.
You could do two things.
1. Generate a batch script as you mentioned.
2. Create two apps, one for generating a dat file and then one that the user can use to read in the dat file and make the necessary changes on the client side.... kind of like an upgrade utility.
Use FSO (file system object) to write the text file
http://www.sloppycode.net/fso/?m=61
You can definately use an app to write registry entries.
Do you have any specific questions?Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
-
March 9th, 2004, 08:17 PM #9
Actually after going through alot of the software's config files the only files that have to be altered in the program's directory are actually 2 text files that have renamed extensions but both files can be easily edited as text files.
So all I would need to do would be to create a wizard program that would export a batch file that in turn would write to the 2 text files in the program's directory and update the registry entries related to the software.
Can this be done with through one batch file generated by the program I create with VB?
In the end I'm trying to create one basic application that we as techs would use to easily create this batch file and just send that batch file to the customer on disk or via email.Last edited by Ritalin Kid; March 9th, 2004 at 08:23 PM.
-
March 10th, 2004, 02:49 AM #10
Yes, you can use VBscript to create a form with inputs, then hit a button to create the bat file for distribution.
Vass is the kowledgeable one on this topic but I can fumble my my though some VBS.
-
March 10th, 2004, 07:45 AM #11Not Really a Member
- Join Date
- Oct 2001
- Posts
- 27,856
I have no idea how to edit a text file in a batch file

I think typically files are just completely written.
If you can dream up a batch file that will do the trick, writing an application or script is fairly easy.
So I'd suggest coming up with a batch file that does the job then you can just quickly write up an app that will generate that file... while writing the batch file make sure to note where the variables are.Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
-
March 10th, 2004, 02:06 PM #12
Here's the tricky part.. One version that we sent out by install file only installs to a different directory than the version of the software we send out on CDROM.
It's been so long since I have written a batch file much less used VB that I'm probably going to need to brush up on my programming skills.
Vass - don't be suprised if I bombard you with questions and if it comes down to it I would be willing to pay for your assistance.
-
March 10th, 2004, 03:35 PM #13
Do you hav a sample of a batch file that does the install routine?
-
March 10th, 2004, 08:22 PM #14
So far I have a sample batch file that writes to the *.txt files in the program's directory. I've never created a batch files that edits the actual registry before so I'm looking for resources on how to do so.
The changes made to the registry are pretty basic so once I figure out how to create a batch file to change the registry entries everything should be set.
-
March 10th, 2004, 08:31 PM #15Not Really a Member
- Join Date
- Oct 2001
- Posts
- 27,856
maybe this will help
http://www.experts-exchange.com/Oper..._20695537.html
If anything the app can generate the .reg file as well, then use regedit from command line to import the reg file.Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
-
March 11th, 2004, 10:14 AM #16
Here's a sample VBscipt that I made for a Paging program. It creates registry entries, creates some folders, copies some files, creates some shortcuts on the user's Desktop, and some other misc.
Not pretty and maybe not real clean but it works correctly.
Code:Option Explicit Dim MyShortcut DIM MyDesktop DIM DesktopPath Dim strComputerName ' Incoming computer name Dim iSeed ' Seed generated for Randomizer Dim iRndNum ' Current random number Dim objNetwork ' WScript Network Object Dim iPos ' Position counter Dim strmail DIM strComputer DIM StdOut DIM oReg DIM strKeyPath DIM PartNum DIM VerNum DIM ClientDir DIM InfoDir DIM strValueName DIM dwValue DIM strValue DIM PrefDir DIM ProgInfoPath Dim objFSO ' FileSystemObject Dim objFiles ' Folder object Files collection for all files in client folder Dim objFile ' File object to copy Dim objFolder ' FSO Folder Object Dim objErrorFile ' Object for Error Log Dim sDestFolder1 ' Folder name for destination Dim sDestFolder2 ' Folder name for destination Dim sDestFolder3 ' Folder name for destination Dim sSourceFolder ' Folder name for source files Dim sErrorLogLoc ' Location for error log, this CAN Be a network location with UNC naming Dim WshShell Dim strScript Set objNetwork = CreateObject("Wscript.Network") strComputerName = objNetwork.ComputerName iSeed = 0 ' Initialize iSeed to 0 to avoid errors For iPos = 1 To Len(strComputerName) iSeed = iSeed + Asc(Mid(strComputerName, iPos, 1)) ' Add up the ascii values of each character to generate the seed Next Randomize iSeed ' Insert the seed into the randomizer ' allows the numbers 1 - 9999 iRndNum = Int((9999 * Rnd) + 1) ' this is your unique number const HKEY_CURRENT_USER = &H80000001 strComputer = "." Set StdOut = WScript.StdOut Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\InfoRad" oReg.CreateKey HKEY_CURRENT_USER,strKeyPath PartNum = "\2018-004" strKeyPath = strKeyPath & PartNum oReg.CreateKey HKEY_CURRENT_USER,strKeyPath VerNum = "\9.6" strKeyPath = strKeyPath & VerNum oReg.CreateKey HKEY_CURRENT_USER,strKeyPath ClientDir = "\Client" strKeyPath = strKeyPath & ClientDir oReg.CreateKey HKEY_CURRENT_USER,strKeyPath InfoDir = "\ClientInfo" strKeyPath = strKeyPath & InfoDir oReg.CreateKey HKEY_CURRENT_USER,strKeyPath strValueName = "ClientNumber" dwValue = iRndNum oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'reset message counter for each workstation strValueName = "MessageNumber" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set client info and message path strValueName = "MessagePath" strValue = "\\proxy2\paging$\MSG" oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue 'Set client preferences strKeyPath = "SOFTWARE\InfoRad" & PartNum & VerNum & ClientDir PrefDir = "\Pref" strKeyPath = strKeyPath & PrefDir oReg.CreateKey HKEY_CURRENT_USER,strKeyPath strValueName = "AutoSplit" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue strValueName = "BackdropStyle" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'set directory for backdrop image strValueName = "Bitmap00" strValue = "" oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue 'delete confirmation strValueName = "ConfDelete" dwValue = 1 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'automatic retries strValueName = "RetryAuto" dwValue = 1 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set number of message retries, default is 3 strValueName = "RetryCount" dwValue = 3 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Seconds between each retry attempt, default is 20 strValueName = "RetryDelay" dwValue = 20 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Retry all manual pages strValueName = "RetryManual" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Show Retry alert window, 0 for off, 1 for on strValueName = "RetryWarn" dwValue = 1 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Send queued messages upon clicking Send button, 0 for off, 1 for on strValueName = "SendQonSend" dwValue = 1 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set location of message signature strValueName = "SigState" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Message signature text strValueName = "SigText" strValue = "User" oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue 'Message signature text strValueName = "SMTPReturnAddress" strValue = "user@domain.com" oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue 'Set text color in program window strValueName = "TextColor" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set vertical position of the program window strValueName = "WndXPos" dwValue = 80 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set horizontal position of the program window strValueName = "WndYPos" dwValue = 102 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set program information strKeyPath = "SOFTWARE\InfoRad" & PartNum & VerNum & ClientDir ProgInfoPath = "\ProgInfo" strKeyPath = strKeyPath & ProgInfoPath oReg.CreateKey HKEY_CURRENT_USER,strKeyPath 'Distribution code strValueName = "DistCode" strValue = "3000" oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue 'Set ExpireCount strValueName = "ExpireCount" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set FirstRun strValueName = "FirstRun" dwValue = 1 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set InstallTime strValueName = "InstallTime" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Set InstallTimeCheck strValueName = "InstallTimeCheck" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 'Serial number strValueName = "SerialNo" strValue = "9371785" oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue 'Set revision settings strValueName = "SettingsRevMajor" dwValue = 1 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue strValueName = "SettingsRevMinor" dwValue = 1 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue strValueName = "SettingsRevRelease" dwValue = 0 oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue set WshShell = Wscript.CreateObject ("WScript.Shell") strScript = WScript.ScriptFullName ' Read desktop path using WshSpecialFolders object DesktopPath = WSHShell.SpecialFolders("Desktop") ' Create a shortcut object on the desktop Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & _ "\InfoRad Paging Client.lnk") ' Set shortcut object properties and save it MyShortcut.TargetPath = "\\proxy2\paging$\Enterprise Client.exe" MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("h:\Program Files\InfoRad Enterprise NT Client") MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = _ MyShortcut.Save sDestFolder1 = "H:\Program Files\" sDestFolder2 = "H:\Program Files\InfoRad Enterprise NT Client\" sDestFolder3 = "H:\Program Files\InfoRad Enterprise NT Client\MSG\" sSourceFolder = "\\proxy2\paging$\client\" ' this could also be \\proxy2\paging%\Log\CheckInfoRadLog.txt ' but may not catch all due to contention sErrorLogLoc = "C:\CheckInfoRadLog.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objNetwork = CreateObject("WScript.Network") ' may want to use OpenTextFile if used over network share Set objErrorFile = objFSO.CreateTextFile(sErrorLogLoc, True) ' True to make sure it overwrites --- change to false otherwise Set objFolder = objFSO.GetFolder(sSourceFolder) Set objFiles = objFolder.Files On Error Resume Next If Not objFSO.FolderExists(sDestFolder1) Then objFSO.CreateFolder(sDestFolder1) If Err.Number <> 0 Then objErrorFile.WriteLine Now() & " Error creating folder " & Err.Description End If If Not objFSO.FolderExists(sDestFolder2) Then objFSO.CreateFolder(sDestFolder2) If Err.Number <> 0 Then objErrorFile.WriteLine Now() & " Error creating folder " & Err.Description End If If Not objFSO.FolderExists(sDestFolder3) Then objFSO.CreateFolder(sDestFolder3) If Err.Number <> 0 Then objErrorFile.WriteLine Now() & " Error creating folder " & Err.Description End If For Each objFile In objFiles ' copy all of the files in this directory On Error Resume Next objFSO.CopyFile objFile.Path, sDestFolder3 & objFile.Name, 0 Next msgbox "Completed!"
-
March 11th, 2004, 10:20 AM #17
Here's an example of a form that can be made using VB script.
This particular script actual does a lot of user related setup in Active Directory and other programs even though it looks simple from the surface.
Note: I had to use a 3rd party OCX control (it may have been free)Last edited by DVNT1; March 11th, 2004 at 10:30 AM.
-
March 11th, 2004, 10:25 AM #18Not Really a Member
- Join Date
- Oct 2001
- Posts
- 27,856
Nice work DVNT1!
I've seen people that have coded for a few years and not code that cleanly
I tend to be a bit anal about spacing, I work with a guy (not a full time coder, he's still learning) ... he doesn't have ONE extra space in between lines in the entire script
Bugs me
Also good to see you use 'Option Explicit' to require DIM's, most network admins just write it good enough to work and don't worry about DIM'ing variables. (another pet peave of mine)
Nice work

RK - DVNT's example is good for what you will be doing and let us know if you have any questions
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
-
March 11th, 2004, 10:30 AM #19
Thanks Vass, to be clear, I didn't hand write it from scratch. I used other examples and perhaps even had help from you on this one (as individual questions anyway).
-
March 11th, 2004, 10:37 AM #20Not Really a Member
- Join Date
- Oct 2001
- Posts
- 27,856
Very well understood, I still copy and paste from other sources

YGPM alsoHelicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)



LinkBack URL
About LinkBacks



Reply With Quote

i seem to have two problems. 1.left an "a" out of a thread title. should be "Can't" not "C'nt", and a partition i can't remove because i can't see it.
Is It Just Me? v233893843