Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 08 Aug 2016 13:12
Works for me.
Are you trying to write the output to the root of the system drive?
-
EddieJRainer
- Posts: 3
- Joined: 08 Aug 2016 11:07
#3
Post
by EddieJRainer » 08 Aug 2016 13:47
Squashman wrote:Works for me.
Are you trying to write the output to the root of the system drive?
I'm trying to record the name of the AV to the "gettxt.txt" file. In my case, the AV is Windows Defender. When the script executes, I want the output, in this case "Windows Defender", to be written to the text file. The program runs, but no output is written to the text file.
When you said it worked for you, were you operating in the C:\ drive?
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#4
Post
by aGerman » 08 Aug 2016 14:04
Users have restricted permissions to write in the C:\ root folder. Is there any specific reason why you can't run it in a subfolder?
Regards
aGerman
-
EddieJRainer
- Posts: 3
- Joined: 08 Aug 2016 11:07
#5
Post
by EddieJRainer » 08 Aug 2016 14:20
aGerman wrote:Users have restricted permissions to write in the C:\ root folder. Is there any specific reason why you can't run it in a subfolder?
Regards
aGerman
Yes, running it in a subfolder works, It's just easier to run in the c:\ drive because I don't have to exactly know what the user name is.
But, what you suggested works. If you know of a way to write to the C:\ drive, it would be great, but if not, it's fine.
Thank you.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#6
Post
by Squashman » 08 Aug 2016 14:23
EddieJRainer wrote:aGerman wrote:Users have restricted permissions to write in the C:\ root folder. Is there any specific reason why you can't run it in a subfolder?
Regards
aGerman
Yes, running it in a subfolder works, It's just easier to run in the c:\ drive because I don't have to exactly know what the user name is.
But, what you suggested works. If you know of a way to write to the C:\ drive, it would be great, but if not, it's fine.
Thank you.
The username is an environmental variable. Open up a cmd prompt and type: SET
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#7
Post
by aGerman » 08 Aug 2016 14:31
EddieJRainer wrote:It's just easier to run in the c:\ drive because I don't have to exactly know what the user name is.
See %userprofile%.
EddieJRainer wrote:If you know of a way to write to the C:\ drive, it would be great, but if not, it's fine.
You should be able to create a subfolder in C:\ using MD.
Regards
aGerman
-
Compo
- Posts: 600
- Joined: 21 Mar 2014 08:50
#8
Post
by Compo » 09 Aug 2016 03:57
You should be able to do it without powershell too.
Antivirus products can put their details in any one of two locations hence the two lines.Code: Select all
@Echo Off
SetLocal
(Set _R=%UserProfile%\Desktop\gettxt.txt)
(Set _N=/NAMESPACE:\\root\SecurityCenter)
>"%_R%" (
WMIc %_N% PATH AntiVirusProduct GET displayName
WMIc %_N%2 PATH AntiVirusProduct GET displayName
)
I cannot test since I've not used an antivirus type product for more than a decade.