Bat to script

Discuss and share scripts and script files...
swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Bat to script

Postby swan_x » 14 Jun 2018 14:00

I have .bat file to terminate 3 process and run one little.exe to clean my empty

run"cmd /c TASKKILL /IM adb.exe /f; cmd /c TASKKILL /IM SynciosDeviceService.exe /f; cmd /c TASKKILL /IM audiodg.exe /f; cmd /c TASKKILL /IM WmiPrvSE.exe /f; D:\apps\EmptyRecycleBin.exe /q"

Then, how to run this on script file??

highend
Posts: 7446
Joined: 06 Feb 2011 00:33

Re: Bat to script

Postby highend » 14 Jun 2018 14:15

Code: Select all

    run """cmd"" /c TASKKILL /IM adb.exe /f";
    // Same procedure for the next two...
    run """D:\apps\EmptyRecycleBin.exe"" /q";
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Re: Bat to script

Postby swan_x » 14 Jun 2018 14:33

Ok highend, I’ve understand. Tanxs for your support! Now i try... bye

swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Re: Bat to script

Postby swan_x » 14 Jun 2018 18:50

I’ve try... the syntax is correct, the script run....
But the 3 process not kill and same my little program (empty recycle) don’t run...
Instead with my .bat file process it’s terminated and same my little prog...
Why the script not kill process??

highend
Posts: 7446
Joined: 06 Feb 2011 00:33

Re: Bat to script

Postby highend » 14 Jun 2018 18:53

Inappropriate permissions?
Killing a running adb instance works fine with that syntax
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Re: Bat to script

Postby swan_x » 14 Jun 2018 19:17

Ok..but only this...i repeat with bat file all work correctly...

highend
Posts: 7446
Joined: 06 Feb 2011 00:33

Re: Bat to script

Postby highend » 14 Jun 2018 20:08

And?

I don't know how the .bat file is started and with which permissions
I don't know with which permissions XY is running
...
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

jupe
Posts: 802
Joined: 20 Oct 2017 21:14

Re: Bat to script

Postby jupe » 15 Jun 2018 04:52

Not sure what you are doing wrong, but if you are interested, a tip for troubleshooting is to run it with a /k instead like below, it is a quick & easy modification that shows if you are getting an error, if it is a permissions issue you should see "Reason: Access is denied."

Code: Select all

run """%COMSPEC%"" /k taskkill /im ""adb.exe"" /f";

I usually run taskkill without the CMD prefix, but for troubleshooting it is handy.

swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Re: Bat to script

Postby swan_x » 15 Jun 2018 11:44

@ jupe
tanxs to your reply, now I try

@ highend
No particular permission when run bat file... simply i have created with notepad, change extension from .txt to .bat then with assigned letter i run it from xy... simply that! and work fine!
When run same command with script, process not killed!!

swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Re: Bat to script

Postby swan_x » 16 Jun 2018 11:00

ok now work fine! but ....
afetr many attemps, correct syntax not required // into single process:

run """cmd"" /c TASKKILL /IM adb.exe /f"; run """cmd"" /c TASKKILL /IM SynciosDeviceService.exe /f"; run """cmd"" /c TASKKILL /IM WmiPrvSE.exe /f"; run """D:\apps\EmptyRecycleBin.exe"" /q"

but this command open (and close) 3 windows to terminate 3 single killing process... how to have only one single window to kill all process??

highend
Posts: 7446
Joined: 06 Feb 2011 00:33

Re: Bat to script

Postby highend » 16 Jun 2018 11:09

ok now work fine!

And because of what?...

taskkill supports MULTIPLE /IM switches in ONE line...

and the script command run can hide a dos box for
emptyrecyclebin.exe (if it actually invokes one)
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Re: Bat to script

Postby swan_x » 16 Jun 2018 18:54

Now work fine because before of my post (with // into process) the script not killed process!
Now, without//, all process is killed!
But, i repeat, with latest syntax all work but I have 3 windows of cmd.... it’s no possible (how to?) have only one cmd to kill 3 process together?

highend
Posts: 7446
Joined: 06 Feb 2011 00:33

Re: Bat to script

Postby highend » 16 Jun 2018 19:03

Em, the answer is already in my last post?
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

swan_x
Posts: 185
Joined: 08 Oct 2009 12:27

Re: Bat to script

Postby swan_x » 16 Jun 2018 19:11

You don’t understand me!
I want the correct string, text, script to run 3 kill process into 1 cmd...

Repeat with my post I have 3 windows... it’s more difficult for you write correct script for this?
I’m not able and I cannot do this...write, or if you don’t want help me, please don’t reply, I wait another generous user.....

jupe
Posts: 802
Joined: 20 Oct 2017 21:14

Re: Bat to script

Postby jupe » 17 Jun 2018 01:39

Something like this should work as a one liner:

Code: Select all

run """%COMSPEC%"" /c TASKKILL /IM adb.exe /IM SynciosDeviceService.exe /IM WmiPrvSE.exe /f",,,0;

In the future if you have trouble writing scripts, but already have a working batch file, it might be better for you to keep the batch file and just run it like this:

Code: Select all

runq "c:\path\to\a batch\file\that works.bat";


Return to “Script Exchange”



Who is online

Users browsing this forum: No registered users and 0 guests