Help writing a .bat file to launch a windows script.
Moderator: DosItHelp
Help writing a .bat file to launch a windows script.
I'm trying to create a simple .bat file to run GPUView with a click of a icon. I need to run "log.cmd" from the "C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview" directory in an Administrativs CMD Prompt. I dont have much experience with .bat files so any help would be appreciated.
This is my latest attempt:
START "runas /user:administrator" cmd /K "cd C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview\log.cmd"
But I get a "The directory name is invalid." message.
This is my latest attempt:
START "runas /user:administrator" cmd /K "cd C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview\log.cmd"
But I get a "The directory name is invalid." message.
Re: Help writing a .bat file to launch a windows script.
Try that
Regards
aGerman
Code: Select all
START "runas /user:administrator" cmd /c "cd "C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview" &call "log.cmd""
Regards
aGerman
Re: Help writing a .bat file to launch a windows script.
Thanks that works! But is there a way to keep the CMD Prompt window open after the script has executed?
Re: Help writing a .bat file to launch a windows script.
My fault. I changed your cmd /k to cmd /c. You just have to change it back.
Regards
aGerman
Regards
aGerman
Re: Help writing a .bat file to launch a windows script.
The start command should begin like this to cater for the title field that had made people bald ever since it was added to Windows.
People tear their hair out in frustration.
Your runas command isn't being launched, in the way I understand it.
Code: Select all
start ""
People tear their hair out in frustration.
Your runas command isn't being launched, in the way I understand it.
Re: Help writing a .bat file to launch a windows script.
A few minutes ago I explained it in a German forum but I didn't even notice it in this thread
Re: Help writing a .bat file to launch a windows script.
aGerman wrote:A few minutes ago I explained it in a German forum but I didn't even notice it in this thread
I've been in that position so many times myself with different things.
Eyeballs MK 1 aren't all that reliable.
Re: Help writing a .bat file to launch a windows script.
aGerman wrote:My fault. I changed your cmd /k to cmd /c. You just have to change it back.
Regards
aGerman
Thank you!
This takes me to my next problem. While the CMD window is open i need it to wait for 45 seconds and then i need it to send "log.cmd" again to stop the GPUView capture.
Heres my non working attempt:
Code: Select all
START "runas /user:administrator" cmd /k "cd "C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview" &call "log.cmd"
SLEEP 45
&call "log.cmd""
Re: Help writing a .bat file to launch a windows script.
SLEEP has been replaced with the TIMEOUT command.
Re: Help writing a .bat file to launch a windows script.
TIMEOUT worked! But the Timeout countdown is happening in a new CMD window. I need the timeout to happen in the original window that we call "log.cmd" on. and then call "log.cmd" again after the timeout.
Re: Help writing a .bat file to launch a windows script.
Manveer Dhillon wrote:Heres my non working attempt:Code: Select all
START "runas /user:administrator" cmd /k "cd "C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview"
You didn't understand my post. And we don't know what you expect from the runas command.
Re: Help writing a .bat file to launch a windows script.
Yes my runas command is not working. With that command I just want to run this .bat file as Administrator.
Re: Help writing a .bat file to launch a windows script.
Try
No idea what you are talking about. The RUNAS will be applied to the cmd /k and thus, it's also applied to the log.cmd. You will be asked to enter the password for the administrator account.
Regards
aGerman
Code: Select all
START "" runas /user:administrator "cmd /k \"cd \"C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview\"^&call \"log.cmd\"\""
Manveer Dhillon wrote:Yes my runas command is not working. With that command I just want to run this .bat file as Administrator.
No idea what you are talking about. The RUNAS will be applied to the cmd /k and thus, it's also applied to the log.cmd. You will be asked to enter the password for the administrator account.
Regards
aGerman
Re: Help writing a .bat file to launch a windows script.
Manveer Dhillon wrote:Yes my runas command is not working.
Did you sort that out?
Is it this script meant for your own machine, or for general use on other PCs?