Script only by computer name...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Batch File script - by computer name

#16 Post by Squashman » 07 Mar 2018 08:55

You were already given the proper syntax for this process in your last thread. DO NOT DUPLICATE YOUR QUESTIONS!

I am merging your topics together!!!!!!!

gilb
Posts: 11
Joined: 15 Feb 2018 06:08

Re: Script only by computer name...

#17 Post by gilb » 08 Mar 2018 05:26

Getting:

The syntax of the command is incorrect

What I'm doing wrong?

Code: Select all

IF /I "%COMPUTERNAME:~0,3%"=="PCM" (
	\\test\bginfo.exe \\test\pcmDesktop.bgi /timer:0 /silent /accepteula
) ELSE IF /i "%computername:~0,3%"=="PCS" (
	\\arkiants\it$\test\bginfo.exe \\arkiants\it$\test\pcsdesktop.bgi /timer:0 /silent /accepteula
) ELSE IF /i "%computername:~0,2%"=="PC"(
	\\test\bginfo.exe \\test\pcdesktop.bgi /timer:0 /silent /accepteula
)

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Script only by computer name...

#18 Post by Squashman » 08 Mar 2018 08:11

You are missing a space before the last left parentheses.

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: Script only by computer name...

#19 Post by SIMMS7400 » 11 Mar 2018 09:35

I'd also quote your paths considering some contain special characters...

gilb
Posts: 11
Joined: 15 Feb 2018 06:08

Re: Script only by computer name...

#20 Post by gilb » 17 Mar 2018 02:18

Code: Select all

@echo off

IF /I %COMPUTERNAME:~0,6%=="mokedm"

then

(\\test\bginfo.exe \\arkiants\it$\test\4.bgi /timer:0 /silent /accepteula)

ELSE IF /i %computername:~0,5%%== "moked"

then

(\\test\bginfo.exe \\arkiants\it$\test\3.bgi /timer:0 /silent /accepteula)

ELSE IF /i %computername:~0,3%%== "sdv"

then

(\\test\bginfo.exe \\arkiants\it$\test\2.bgi /timer:0 /silent /accepteula)
PC NAMES:
moked01
mokedm02
sdv01

Not working why?

GETTING THIS:
The syntax of the command is incorrect

Thanks,

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Script only by computer name...

#21 Post by penpen » 17 Mar 2018 07:57

The first if-command in your file is the following:

Code: Select all

IF /I %COMPUTERNAME:~0,6%=="mokedm"
The syntax of the above if-command is as follows:

Code: Select all

if [/i] <String1> <CompareOp> <String2> <Command>
So the processor sees:
- processing: "if"-command
- using option "/i": true
- <String1>: %COMPUTERNAME:~0,6%
- <CompareOp>: ==
- <String2>: "mokedm"
- <Command> is not present => Syntax error


penpen

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Script only by computer name...

#22 Post by Squashman » 17 Mar 2018 11:41

Locking this thread until I get a reply from user.

Locked