Scripting Question

How do i take userinput?

07/03/2017 577 views
I am trying to get a userinput, kind of like the PromptPCname task.
I have made a BAT file like this:
@Echo off
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"


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

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)]

Answer Summary:
0 Comments   [ + ] Show comments


Answer Chosen by the Author

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!
Answered 07/04/2017 by: bok
White Belt

All Answers

This content is currently hidden from public view.
Reason: Removed by member request For more information, visit our FAQ's.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


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