Jump to content

PowerShell comand in CMD script

Hey Guys,

So the dealio is this. I'm trying to run a powershell command in a cmd script of mine.

My power shell knowledge is very limited, so I understand this may just be a simple fix to some you :)

This is what I am attempting to run:

powershell -command Import-StartLayout –LayoutPath C:\Windows\Temp\Startmenudef.xml -MountPath $env:SystemDrive

The error I get back is attached...Capture.PNG.fa56b481d52e8faf93de6bafaf6758b7.PNG

I have googled and tried all sorts of different quotation marks and parameter definers, but I can't seem to get it to work. The command itself runs fine in admin mode powershell, I will also attach a screenshot of this... Capture1.PNG.75c43327816623775c69646a319be705.PNG

 

Any help would be greatly appreciated.

Thank you.

 

- Samuel

Samuel Edwards

- IT Engineer and Media Producer -

Religious theology diploma and over half a dozen certificates in Advanced Computing and IT.

Current Project:   Mineral Oil Cooled PC

Just trying to be friendly and help where I can. Have yourself a great day!

Use @SamuelJE for friendly tech help :)

 

 

 

Main PC - "The Genesis"

Mobo   -   Gigabyte GA-H170-Gaming 3

CPU     -   intel i5-6600K 4Ghz on water

GPU     -   MSI GTX970 "Red Dragon"

Case    -   Zalman Z11 Plus (Custom RGB Obviously, It's 2017 bro...)

OSD     -   Crucial 275GB M.2 SSD

SSD     -   Crucial 250GB SATA SSD

HDD    -    4TB WD Green x 2

Disp     -   LG ultra wide Gaming Monitor

 

Secondary PC - "Jonah"   (Mineral oil PC)

Mobo   -   Gigabyte GA-B250-DH1

CPU     -   intel i5-7500 Under Oil

GPU     -   Nvidia GTX 660 (Favorite and first ever GPU)

Case    -   A Fish Tank W/ Custom Engineered Mounting System (Custom RGB Obviously, It's 2017 bro...)

OSD     -   Crucial 275GB M.2 SSD

HDD    -    2TB WD Green

Disp     -   LG ultra wide Gaming Monitor

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 6/20/2017 at 9:35 AM, SamuelJE said:

-snip-

can you please post the contents of the Startmenudef.xml file so I can try to reproduce your issue. Also in the meantime try to put C:\Windows\Temp\Startmenudef.xml in quotations like this:

 

powershell -command Import-StartLayout –LayoutPath "C:\Windows\Temp\Startmenudef.xml" -MountPath $env:SystemDrive

 

And the final question is, are you running this command as admin? If not try doing that.

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks!

Yep I'll attach the file. I have tried quotation marks but to no avail, and the script requires admin rights to run, so it is always started in admin (it actually requests it).

What I since have found to work how ever is this

powershell -command "& {Import-StartLayout -layoutpath C:\Windows\Temp\Startmenudef.xml -MountPath $env:SystemDrive\}"

But it comes back with a slightly less strange error and still doesn't produce the results I'd like.

 

Thanks again.

Regards,

 Samuel

LayoutDef.xml

Samuel Edwards

- IT Engineer and Media Producer -

Religious theology diploma and over half a dozen certificates in Advanced Computing and IT.

Current Project:   Mineral Oil Cooled PC

Just trying to be friendly and help where I can. Have yourself a great day!

Use @SamuelJE for friendly tech help :)

 

 

 

Main PC - "The Genesis"

Mobo   -   Gigabyte GA-H170-Gaming 3

CPU     -   intel i5-6600K 4Ghz on water

GPU     -   MSI GTX970 "Red Dragon"

Case    -   Zalman Z11 Plus (Custom RGB Obviously, It's 2017 bro...)

OSD     -   Crucial 275GB M.2 SSD

SSD     -   Crucial 250GB SATA SSD

HDD    -    4TB WD Green x 2

Disp     -   LG ultra wide Gaming Monitor

 

Secondary PC - "Jonah"   (Mineral oil PC)

Mobo   -   Gigabyte GA-B250-DH1

CPU     -   intel i5-7500 Under Oil

GPU     -   Nvidia GTX 660 (Favorite and first ever GPU)

Case    -   A Fish Tank W/ Custom Engineered Mounting System (Custom RGB Obviously, It's 2017 bro...)

OSD     -   Crucial 275GB M.2 SSD

HDD    -    2TB WD Green

Disp     -   LG ultra wide Gaming Monitor

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×