Bat to script

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

Bat to script

Post by swan_x »

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: 13274
Joined: 06 Feb 2011 00:33

Re: Bat to script

Post by highend »

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

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

Re: Bat to script

Post by swan_x »

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

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

Re: Bat to script

Post by swan_x »

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: 13274
Joined: 06 Feb 2011 00:33

Re: Bat to script

Post by highend »

Inappropriate permissions?
Killing a running adb instance works fine with that syntax
One of my scripts helped you out? Please donate via Paypal

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

Re: Bat to script

Post by swan_x »

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

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

Re: Bat to script

Post by highend »

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

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Bat to script

Post by jupe »

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: 321
Joined: 08 Oct 2009 12:27

Re: Bat to script

Post by swan_x »

@ 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: 321
Joined: 08 Oct 2009 12:27

Re: Bat to script

Post by swan_x »

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: 13274
Joined: 06 Feb 2011 00:33

Re: Bat to script

Post by highend »

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

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

Re: Bat to script

Post by swan_x »

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: 13274
Joined: 06 Feb 2011 00:33

Re: Bat to script

Post by highend »

Em, the answer is already in my last post?
One of my scripts helped you out? Please donate via Paypal

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

Re: Bat to script

Post by swan_x »

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: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Bat to script

Post by jupe »

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";

Post Reply