/build/static/layout/Breadcrumb_cap_w.png

How do i take userinput?

I am trying to get a userinput, kind of like the PromptPCname task.
I have made a BAT file like this:
@Echo off
cls
echo 1. Office
echo 2. Production
CHOICE /C 12 /M "Choose setup style"

md "x:\movead"
copy adminpassword.txt "x:\movead"
copy key.txt "x:\movead"

IF ERRORLEVEL 2 GOTO Production
IF ERRORLEVEL 1 GOTO Office


:Production
copy PRODUCTION.ps1 "x:\movead\moveAD.ps1"
exit
:Office
copy Office.ps1 "x:\movead\moveAD.ps1"
exit

When i run it on my PC it works flawlessly, but in the kace environment the task ends up in the background (i see it for a split second) and fails, because the script "hangs" when no user input is given.


What i try to accomplish is this:

Copy the right files to the directory x:\movead depending on the user choice. [preinstall]

Move x:\movead to c:\movead  [mid-level task]

execute C:\movead\moveAD.ps1. This will now move the PC to the right AD directory, making the k1000 server do the rest of the setup. [post install (last task)]


0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: bok 7 years ago
White Belt
0

Top Answer

Quick answer
Use vb script for this.
This seems to be the easiest.

Long answer
I tried to solve this in several ways.
C++ = too hard for me to make a proper GUI.
C# = Not able to run as pre-install task
Visual basic = not able to run as pre install task.

In the end, i started reading up on VB scripts, and came up with this solution.
Option Explicitdim Officedim fsoset fso = CreateObject("Scripting.FileSystemObject")'checking if folder existsIf fso.FolderExists("x:\MoveAD") thenelse    fso.CreateFolder "x:\MoveAD"end if' moving common filesfso.CopyFile "Y:\preinstall\23\contents\key.txt", "x:\MoveAD\"fso.CopyFile "Y:\preinstall\23\contents\adminpassword.txt", "x:\MoveAD\"' Asking if this is an office pcOffice = MsgBox("Is this an office PC?",4,  "Office PC")' moving script depending on office or production setupIf Office = vbYes then	fso.CopyFile "Y:\preinstall\23\contents\OFFICE.ps1", "x:\MoveAD\MoveAD.ps1"Else	fso.CopyFile "Y:\preinstall\23\contents\PRODUCTION.ps1", "x:\MoveAD\MoveAD.ps1"end if


I zipped all my files, and added them as an application.
For the command to run, i used cscript.exe Y:\preinstall\23\contents\SetupType.vbs

Hope this helps out others in the future!
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ