Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Clanpot Shake
Aug 10, 2006
shake shake!

I'm not sure if this is the best place to ask, but I've got a question for people who know Windows scripting. We have an AD setup where about half of the users are missing a piece of required software. Rather than installing this one by one, we want to run a logon script to install and configure it using elevated privileges. We're a newly setup department so we don't have SCCM or similar to push out software yet, so this will be a one-time thing.

I started looking into this and found we could use VBScript to run commands, but I haven't been able to get it to do what I want. I've got the logic right, I'm just struggling with how VBScript handles certain things. In particular, I can't seem to get it to call the installer .exe file, but I also can't see any errors because it's running quiet.

Is this the right approach, or is there a better/easier alternative for installing software than VBScript? Are there any resources/examples of doing this?

Adbot
ADBOT LOVES YOU

Clanpot Shake
Aug 10, 2006
shake shake!

I'm writing a pre-commit git hook in powershell that checks the syntax of Ruby files. The command I'd like to run is:
code:
  ($file is loop variable)
$erb = "C:\opscode\chef\embedded\bin\erb.bat -P -x -T '-'"
$ruby_exe = "C:\opscode\chef\embedded\bin\ruby.exe"
& $erb $file | $ruby_exe -c
I get this error:

quote:

The term 'C:\opscode\chef\embedded\bin\erb.bat -P -x -T '-' <file path> | C:\opscode\chef\embedded\bin\ruby.exe -c' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I'm clearly not doing this right. How do I run a command and pipe the output to another command?

Clanpot Shake
Aug 10, 2006
shake shake!

SniperWoreConverse posted:

Try dropping the quotes, that way your variables will be the files you want instead of a string that happens to be the path to the file. (I think, dunno about the -P -x -T stuff)

e:
code:
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

PS C:\> .\b.bat

C:\>echo butts
butts
PS C:\> C:\b.bat

C:\>echo butts
butts
PS C:\> $b = ".\b.bat"
PS C:\> $b
.\b.bat
PS C:\> $b = .\b.bat
PS C:\> $b

C:\>echo butts
butts
$erb = C:\opscode\chef\embedded\bin\erb.bat -P -x

C:\chef-repo>powershell.exe -ExecutionPolicy RemoteSigned -File .git\hooks\pre-commit-hook.ps1
You must provide a value expression on the right-hand side of the '-' operator.
At C:\chef-repo\.git\hooks\pre-commit-hook.ps1:58 char:48
+ $errors = & $erb $file | $php_bin - <<<< c $file
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : ExpectedValueExpression

Clanpot Shake
Aug 10, 2006
shake shake!

I changed it to
code:
$errors = & C:\opscode\chef\embedded\bin\erb.bat -P -x $file | C:\opscode\chef\embedded\bin\ruby.exe -c
and it works. I don't fully understand it, but playing around with it told me it wasn't necessarily the -c it had a problem with.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply