Deploy a command to remote computer with switch?

What's the best way to put this command into a CMD, batch or VBS file that can be deployed to a remote computer?

C:\Windows\System32\Fbwfmgr.exe /addexclusion C: \Windows\System32\Microsoft

Open in new window

As you can see here I'm trying to exclude that "Microsoft" folder in system32 from the file based write filter on a thin client that's running Windows XP Embedded.

If I save this code into a .cmd file:
"C:\Windows\System32\Fbwfmgr.exe" /addexclusion C: \Windows\System32\Microsoft

Open in new window

And then deploy it to a remote computer using PDQ Deploy, it says it fails. But when I check the remote computer, I show the C:\Windows\System32\Microsoft patch is now added in the File Based Write Filter exclusion list...
Who is Participating?
If a command runs in Windows and there is not an error, it sets errorlevel to 0.  If you open a CMD prompt, then type echo %errorlevel%, it will most likely return a zero.

Your batch file could check the value of errorlevel (if errorlevel = 0 or some such) and use that to see if the command actually completed successfully.
Gary DewrellSenior Network AdministratorCommented:
What is the error you are getting?
If you ran the command on the server manualy does it still give you an error?
garryshapeAuthor Commented:
If I run it manually in the command prompt, no errors.
Says the path will be in the exclusion list after the next reboot.

If I run it via PSExec, it says it cannot find the exe path.
If I run it via PDQ Deploy, it just says failed. Usually would say success if I deployed something like an MSI file. Maybe it has no way of knowing this command has run then, which seems strange.
But via PDQ Deploy it seems to still affect the remote computer successfully, I just see a "failed" still.
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

garryshapeAuthor Commented:
It is 0.
PDQ Deploy says it checks for code 0,1641,3010.
Should I just add a new line with "exit" to the cmd file?
That's what I would do.

And for more info on Windows variables, go here:

You might have your cmd check the %errorlevel% immediately after your command runs and do something if it is not 0.
another handy thing is Return:
If %errorlevel% not equal 0 then return %errorlevel%

Not sure of the exact syntax, but this way you know what the error number is.
garryshapeAuthor Commented:
Looks like I even get the -1 error if I run the command using psexec (launching psexec \\remotecomputer CMD then running.

I type “C:\WINDOWS\system32>fbwfmgr /addexclusion C: \Windows\System32\Microsoft”
Then it returns:
“Path \Windows\System32\Microsoft on volume C: will be in the exclusion list after the next reboot.”
Then I exit:
And I see:
“cmd exited on dfw-tl-2642 with error code -1.”

So it must be this particular command.
garryshapeAuthor Commented:
Thanks for help. It appears the particular exe utility I'm working with isn't compatible from what I can tell with returning an error code other than -1 if I run remotely.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.