Hi all,

I'm trying to setup an MI to install a piece of software. Not normally a problem (I've got quite good at it now), unfortunately this particular piece of software stores a "server" variable as a file in the user's app dir.

Hmm... so stage 1 is to install the software as the local system account and then stage 2 it needs to get to the Current User (logged onto console) context to copy said file to %USERPROFILE%\Application Data\Program\server\file".

Now, I thought I could be clever and do an MI with a bat file that ran the install, then called runkbot.exe and passed it the script's number.

Sadly, this doesn't seem to have worked, in fact I can't see any evidance the script has been run.

Anyone come across this and got a working method?
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
I would use a script with two tasks:

general steps:
task 1:
  • verify:check for software
  • success:
  • remediation: install it

task2:
  • verify: check for software
  • success: batch file that copies file to current user folder.

For some code to help with the batch file:
http://www.kace.com/support/kb/index.php?action=artikel&cat=5&id=698&artlang=en
Answered 01/09/2012 by: GillySpy
Seventh Degree Black Belt

Please log in to comment
0
Well, our normal process is assign label to PC, and force an inventory to install software.

I'd rather use scripts behind the scenes and not for deploying the software.

Hmm... that ZIP file download link on the KB article is broken.
I've also not imported any resources yet... so will have to look that up for the other download
Answered 01/09/2012 by: AJStevens
Purple Belt

Please log in to comment
0
Hey AJ,

Does the file need to be placed in all the users' folders, or just the current user? My thought was to iterate over all the user folders in documents and settings (I'm assuming XP?) and drop it in as part of the install batch file. Before I stuck some code together I thought I'd check to see what you thought.

I'm with you, I usually try to install with MIs and leave the scripts to other things.

Casey
Answered 01/09/2012 by: cmccracken
Orange Senior Belt

Please log in to comment
0
Hi Casey,

Just the current logged in console user would be best, I say that because normally there's only one user per machine, however some of the machines have been in use and circulation they could be bloated with old profiles and there's no sense in a script running through all of them adding in the two files.

Be aware, we've had some domain changes, so it really does need to isolate the console user, then obtain their correct profile dir. Which if it's not getting via %USERPROFILE%, you'll have to get it from the Registry and that'll mean working out the SID... *headache starts*.
Answered 01/09/2012 by: AJStevens
Purple Belt

Please log in to comment
0
You could do it with a batch in an MI but you'll have to zip things up and attach that to the software.

If you're doing batch files in MIs then what do you leave scripts for? I'm not saying you should use a script just that wondering where you personally draw the line? I personally think a script makes this easier as all the conditional steps are laid out logically and some of the writing (eg the batch file) can be done in the script, but there are definitely many approaches ones can take.

If it helps, when you use an offline script then you can schedule it to run at next checkin (the same time an MI runs) by setting the schedule to be:
Also Run Once at next Client Checkin
Answered 01/09/2012 by: GillySpy
Seventh Degree Black Belt

Please log in to comment
0
I believe powershell can help.

I've done a few tests on one of our Windows 7 PCs and just a moment ago on a Windows XP machine and the below code (customized for XP) will pull the currently logged in user and copy a file from the same folder as the script to their desktop.


$name = (get-wmiobject win32_computersystem).UserName.Split("\")[1]
$path = "C:\Documents and Settings\" + $name + "\Desktop"
copy-item "setup.bat" $path


Code in my setup.bat file


::Allow powershell scripts to run
C:\system32\WindowsPowerShell\v1.0\powershell.exe Set-ExecutionPolicy RemoteSigned
C:\system32\WindowsPowerShell\v1.0\powershell.exe .\test.ps1


Personally, I leave scripts for configurations, such as disabling updaters, enforcing application restrictions, etc.

Casey
Answered 01/09/2012 by: cmccracken
Orange Senior Belt

Please log in to comment
0
That's fine, most of our MI's are a zipped file and it calls a batch to install it, mostly because the whole MSIEXEC seems to be broken in KBOX, so we have it call a batch and put our MSIEXEC line and arguments in there.

Looking at our current scripts, they do things like complex or secure uninstalls of stubborn or designed to be stubborn programs, update user settings (VPN), or collect information on the PC for KBOX to pick up by a custom inventory item.
They're not the day to day things the support run, more the second/third line, I like to keep it simple for them and "LABEL = Software install".

cmccracken, great code, thanks for that.
Answered 01/10/2012 by: AJStevens
Purple Belt

Please log in to comment
0
My other thought was to find the most recently modified user folder, but I hadn't dug up any code to do it yet.

I use smart labels to install most of my software. As an example, for our anti-virus, the smart label M_NeedAntiVirus checks to see if the AV is in the software title. The MI is then tied to that smart label. For the software that isn't given to all users I use two labels. I assign a label (Ex. Office2003) and the smart label checks for the existance of my label, and that the software isn't in the software titles.

I've only used powershell for a few things (hopefully more now that its part of Win 7), and cobbled the code together from a few pages. For just WMI, this vbscript will pull the domain\username.


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
WScript.Echo objComputer.UserName
Next


(From http://msdn.microsoft.com/en-us/library/windows/desktop/aa394586(v=vs.85).aspx).

Casey
Answered 01/10/2012 by: cmccracken
Orange Senior Belt

Please log in to comment
0
Cool, thanks cmccracken.
Answered 01/10/2012 by: AJStevens
Purple Belt

Please log in to comment
Answer this question or Comment on this question for clarity