K2000 - How to preserve output from pre-install prompting script that I wrote, to be used later by post-install tasks
I’m still fairly new to scripting and I’ve been trying to figure out a problem that I’m hoping maybe someone can help me with.
What I’m trying to do:
THE GIST: I wanted a pre-installation task that runs right after the “get/set computer name.exe” task from KACE and prompts the user to a few questions and then stores the answers to be used later on during the post-install phase. This way certain post-installation software installs can use those answers to see if they should install that program or not. I wanted it to run right at the beginning of the entire scripted installation process so the tech can set computer name and also these install details right away and then come back later with everything done. We have some computers like checkouts that aren’t on the domain so that’s why I want the post-install tasks themselves to decide whether they run or not (not depending on any domain or server input).
The problem is really just one detail: How do I keep safe the little bat file I’m outputting from my vbs script at the pre-installation stage and put it somewhere on the structured C drive (after Windows has installed) so that I can call my information that I want from it?
I’ve tried putting the file in the X:\Applications\ and the Y:\preinstall locations that I thought were created to store pre-install task data. I tried including a folder with a blank copy of the outputted bat file (to be overwritten by my script) with my KBE, using the KBE manipulator. Clearly this aspect is beyond me as I’m grasping at straws. But I think it’d be really cool to know how to do this and make this idea work.
The Process I’m trying to build:
1. [THIS PART WORKS WELL] A pre-installation task runs before I run the disk prep tasks. I’m using a vbs script based on what I’ve gotten from the “old get/set computer name” script from KACE. It prompts the user/tech with a few questions:
a. “Is this a shared desktop?”
b. “What work area is this used in?”
c. “Is this a checkout laptop?”
d. ** The one-word answers obtained from the user are output to a bat file as variables to be called later (this works if I did it on a computer that already has a Windows file structure and I just put it in C:\temp or anywhere else).
2. [THIS PART FAILS] I need the bat file stored in a temporary location because as a pre-install task, there is no Windows file structure. When Windows has installed and created a file structure, then I need to move my little info file to the C drive to be used by post-install tasks.
Here are the scripts showing the last way I tried to do this. I’d like to see what kind of constructive advice I get on how to make this work or do something better. I’ll probably get people who want to tell me to get a K1000, and we may get the money for that down the road, but I have no idea how long from now that may be. So, this is supposed to be a poor man’s, simpler substitute for right now.
'This script displays an input box to gather a few details about a computer system 'being installed, such as the physical work location and the status of being shared 'or not. The user input for these questions is put into a text file stored in the 'KACE application directory, which is purged at the end of the KACE scripted install process. Option Explicit '---------- FIND DRIVES ---------- DIM diskDrives Set fso = CreateObject("Scripting.FileSystemObject") Set diskDrives = fso.Drives '---------- OBTAIN THE NEEDED PREINSTALL INFORMATION WITH POP-UP PROMPTS ----------- 'ASK THE NECESSARY QUESTIONS DIM value, fso, NewsFile, strSHARED, strPHYSLOC, strCHECKOUT 'Set wshShell = WScript.CreateObject( "WScript.Shell" ) MsgBox("Hello and welcome to the joy of loading a computer. Please answer the next few questions that appear. Thank you.") strSHARED = inputbox("Is this a shared desktop? (y/n)") strPHYSLOC = inputbox("Physical work group/location:") strCHECKOUT = inputbox("Is this a checkout laptop? (y/n)") MsgBox("That helped a lot. Beginning computer reload process...") '---------- MAP X DRIVE AND CREATE DIRECTORY ---------- Dim objFSO, objFSOText, objFolder, objFile Dim strDirectory, strFile strDirectory = "X:\Applications\LCSO" strFile = "\LCSOPreinstallInfo.bat" '---------- Create file system object ------------- Set objFSO = CreateObject("Scripting.FileSystemObject") '--- Check, then create File System Object if not there ---- '--- Check that the strDirectory folder exists ------------- If objFSO.FolderExists(strDirectory) Then Set objFolder = objFSO.GetFolder(strDirectory) Else Set objFolder = objFSO.CreateFolder(strDirectory) End If '-------- Create the file specified by strFile ---------- If fso.DriveExists("X:") then Set NewsFile = fso.CreateTextFile(strDirectory & strFile, True) Else usbDrive = fso.GetDriveName(wscript.ScriptFullName) Set NewsFile = fso.CreateTextFile(usbDrive & "\KACE" & strFile, True) End If '---------- OUTPUT THE PREINSTALL INFORMATION ----------- NewsFile.WriteLine "@ECHO OFF" NewsFile.WriteLine ":: [LCSOPreinstallInfo]" NewsFile.WriteLine ":: THIS FILE CONTAINS VARIABLES FROM THE PREINSTALL TASK REQUESTING KACE INSTALL INFO" NewsFile.WriteLine "" NewsFile.WriteLine "SET SHARED=" & strSHARED NewsFile.WriteLine "SET PHYSLOC=" & strPHYSLOC NewsFile.WriteLine "SET CHECKOUT=" & strCHECKOUT NewsFile.WriteLine "END" NewsFile.Close
Running these scripts results in the error message below. It comes up after I've completed the question prompts and when the script is trying to save the output file to the X drive, which it doesn't seem to be recognizing (I think).
Windows Script Host
Error: Path not found
Source: Microsoft VBScript runtime error