2017-06-03 41 views
0

我正在使用批處理來製作一個程序,通知有人在其ftp服務器上的程序。現在我有一個腳本來檢查然後發送命令到rainmeter的NXT-OS皮膚來打開通知程序。它通過嘗試從ftp服務器下載文件來實現這一點,因爲如果文件在那裏,則意味着用戶在線。如果不存在,那麼我們知道它不是。我已經設置了這樣的文件不存在。但是現在我正在遇到一個錯誤,它會使通知的哨聲沒有任何彈出框。有人可以看看這段代碼,看看有沒有人在線時它可以發送一半的命令?謝謝!注意:包含的代碼不是全部,因爲代碼包含ftp服務器地址和密碼。謝謝!遇到此批處理代碼的錯誤

Get Rainmeter

(在Windows上運行)

Get NXT-OS

Rem This is where it checks if the files were downloaded 
if exist on.%friend1% set Friend1Stat=On 
if exist on.%friend2% set Friend2Stat=On 
if exist on.%friend3% set Friend3Stat=On 
if exist on.%friend4% set Friend4Stat=On 
if exist on.%friend5% set Friend5Stat=On 


if exist on.%friend1% set /p Friend1Name=<on.%friend1% 
if exist on.%friend2% set /p Friend2Name=<on.%friend2% 
if exist on.%friend3% set /p Friend3Name=<on.%friend3% 
if exist on.%friend4% set /p Friend4Name=<on.%friend4% 
if exist on.%friend5% set /p Friend5Name=<on.%friend5% 
if not exist log.txt echo. >log.txt 
echo %time% %date% >>log.txt 
set >>log.txt 

if %Friend1Stat%==on goto friend1 
goto friend1b 
:back1 
if %friend2stat%==on goto friend2 
goto friend2b 
:back2 

if %friend3stat%==on goto friend3 
goto friend3b 
:back3 

if %friend4stat%==on goto friend4 
goto friend4b 
:back4 

if %friend5stat%==on goto friend5 
goto friend5b 
:back5 

echo Complete. Waiting 60 seconds before starting again. 
choice /c q /d q /t 60 /n 
goto TESTFORFRIENDS 

:friend1 
if %friend1run%==yes goto back1 
set friend1run=yes 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend1', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend1name% is Online', body = '%friend1name% is on their computer.%time%'})" "nxt-os\Notify" 
goto back1 

:friend1b 
if %Friend1run%==no goto back1 
set friend1run=no 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend1', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend1name% is Offline', body = '%friend1name% is no longer on their computer. %time%'})" "nxt-os\Notify" 
goto back1 

:friend2 
if %friend2run%==yes goto back2 
set friend2run=yes 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend2', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend2name% is Online', body = '%friend2name% is on their computer.%time%'})" "nxt-os\Notify" 
goto back2 

:friend2b 
if %Friend2run%==no goto back2 
set friend2run=no 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend2', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend2name% is Offline', body = '%friend2name% is no longer on their computer. %time%'})" "nxt-os\Notify" 
goto back2 


:friend3 
if %friend3run%==yes goto back3 
set friend3run=yes 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend3', style = 3, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend3name% is Online', body = '%friend3name% is on their computer.%time%'})" "nxt-os\Notify" 
goto back3 

:friend3b 
if %Friend3run%==no goto back3 
set friend3run=no 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend3', style = 3, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend3name% is Offline', body = '%friend3name% is no longer on their computer. %time%'})" "nxt-os\Notify" 
goto back3 

:friend4 
if %friend4run%==yes goto back4 
set friend4run=yes 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend4', style = 4, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend4name% is Online', body = '%friend4name% is on their computer.%time%'})" "nxt-os\Notify" 
goto back4 

:friend4b 
if %Friend4run%==not goto back4 
set friend4run=no 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend4', style = 4, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend4name% is Offline', body = '%friend4name% is no longer on their computer. %time%'})" "nxt-os\Notify" 
goto back4 

:friend5 
if %friend5run%==yes goto back5 
set friend5run=yes 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend5', style = 5, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend5name% is Online', body = '%friend5name% is on their computer.%time%'})" "nxt-os\Notify" 
goto back5 

:friend5b 
if %Friend5run%==not goto back5 
set friend5run=no 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend5', style = 5, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend5name% is Offline', body = '%friend5name% is no longer on their computer. %time%'})" "nxt-os\Notify" 
goto back5 




:nosettings 
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'no-settings', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = 'Set Up ITCMD Notifier', body = 'Open the Location of the Notifier and edit settings.ini Then Restart the program.'})" "nxt-os\Notify" 

echo :: Set Friend Usernames here! (Users set their own usernames) >settings.ini 
echo. >>settings.ini 
echo set Friend1=Set>>settings.ini 
echo set Friend2=Set>>settings.ini 
echo Set Friend3=Set>>settings.ini 
echo Set Friend4=Set>>settings.ini 
echo Set Friend5=Set>>settings.ini 
echo. >>settings.ini 
echo. >>settings.ini 
echo :: Note: Do not change anything but the friend uernames! Fatal errors could occur. >>settings.ini 
exit /b 

感謝一大堆提前!如果您有任何問題,請告訴我!

+0

'如果上轉到friend1'%Friend1Stat%==從未進入'friend1'如'設置Friend1Stat = On'和'if'是大小寫敏感的。使用'if/I',或'設置Friend1Stat = on'。此外,你的代碼並不構成[mcve]:例如,缺少初始設置和':TESTFORFRIENDS'標籤。請[編輯]你的問題。這些代碼中包含 – JosefZ

+0

。但是我不能包含它們,因爲它包含個人信息和ftp站點 –

回答

0

我發現在Rainmeter的日誌文件的內容:

Rainmeter: Debugging: ITCMD has sent an invalid notification type 

我意識到,「風格」的人數上升到3 4和5的時候我會用查找和替換%friend2%全部更換號碼或%Friend2Name%以及!無論如何感謝您的幫助。希望這可以幫助其他人!