You were close.
start-process cmd.exe "/c \\server\share\filename.cmd" -WindowStyle Hidden
or
start-process cmd.exe "/c", "\\server\share\filename.cmd" -WindowStyle Hidden
Both work, but the second is "more proper for PowerShell".
The syntax for start-process is:
Start-Process [-FilePath] <string> [[-ArgumentList] <string[]>] [-PassThru]
[-Verb <string>] [-Wait] [-WindowStyle {Normal | Hidden | Minimized |
Maximized}] [-WorkingDirectory <string>] [<CommonParameters>]
Which tells you that ArgumentList has to be a string or a list of strings.
Regards,
Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com
From: James Rankin [mailto:[email protected]]
Sent: Wednesday, March 02, 2011 10:21 AM
To: NT System Admin Issues
Subject: Re: PowerShell noob question
Right, sorry for delay, was in a meeting.
I was trying to use start-process to launch a hidden window and call a script
in a share
I tried
start-process cmd.exe /c
"\\server\share\filename.cmd<file:///\\server\share\filename.cmd>" -WindowStyle
Hidden
start-process "cmd.exe /c
\\server\share\filename.cmd<file:///\\server\share\filename.cmd>" -WindowStyle
Hidden
start-process cmd.exe /c
\\server\share\filename.cmd<file:///\\server\share\filename.cmd> -WindowStyle
Hidden
and all gave the same error, where am I going wrong? I chose a bad day to
start messing about with PS....
On 2 March 2011 14:27, Michael B. Smith
<[email protected]<mailto:[email protected]>> wrote:
Yes. Quoting within PowerShell is an even more arcane art than it is with
cmd.exe. And when you combine them! Oh my!
Regards,
Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com
-----Original Message-----
From: Ben Scott [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, March 02, 2011 9:09 AM
To: NT System Admin Issues
Subject: Re: PowerShell noob question
On Wed, Mar 2, 2011 at 8:59 AM, James Rankin
<[email protected]<mailto:[email protected]>> wrote:
>> > I tried /c, gave me an error
>>
>> What was the error?
>
> It was something like
>
> A positional parameter cannot be found that accepts argument
> "\\server\share\scriptname.cmd<file:///\\server\share\scriptname.cmd>"
That's a PowerShell syntax error. It has nothing to do with CMD.EXE
or any other external program. Your PowerShell code that attempts to
call CMD is not doing so correctly.
Post the code and I bet someone can figure it out. :)
On Wed, Mar 2, 2011 at 9:00 AM, James Rankin
<[email protected]<mailto:[email protected]>> wrote:
> The end goal is to use the enumerated group names to set some environment
> variables. These environment variables are then used to help map the user's
> printers (after they have logged in)
Might be easier to enumerate the groups and set the environment all
within PowerShell. Google finds recipes for both.
-- Ben
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
--
"On two occasions...I have been asked, 'Pray, Mr Babbage, if you put into the
machine wrong figures, will the right answers come out?' I am not able rightly
to apprehend the kind of confusion of ideas that could provoke such a question."
IMPORTANT: This email is intended for the use of the individual addressee(s)
named above and may contain information that is confidential, privileged or
unsuitable for overly sensitive persons with low self-esteem, no sense of
humour or irrational religious beliefs. If you are not the intended recipient,
any dissemination, distribution or copying of this email is not authorised
(either explicitly or implicitly) and constitutes an irritating social faux pas.
Unless the word absquatulation has been used in its correct context somewhere
other than in this warning, it does not have any legal or no grammatical use
and may be ignored. No animals were harmed in the transmission of this email,
although the kelpie next door is living on borrowed time, let me tell you.
Those of you with an overwhelming fear of the unknown will be gratified to
learn that there is no hidden message revealed by reading this warning
backwards, so just ignore that Alert Notice from Microsoft.
However, by pouring a complete circle of salt around yourself and your computer
you can ensure that no harm befalls you and your pets. If you have received
this email in error, please add some nutmeg and egg whites, whisk and place in
a warm oven for 40 minutes.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin